Cloud Custodian filter GCP compute instances that have a label for datetime that's past

404 Views Asked by At

I want to have a cloud custodian policy that marks compute instances for op if they have a label expires-on and it's set to a date/time that's past the time of evaluation.

I tried looking through the cloud custodian documentation but I'm struggling to find anything about "label filtering" for GCP instances

Do you know about any documentation that could help me better understand label filtering?

1

There are 1 best solutions below

1
On

For filtering based on a label, you need to use filter type "value" and as a key, you need to use JSON path:

policies:
  - name: my-first-policy
    resource: gcp.instance
    filters:
      - type: value
        key: labels.labelkey
        value: labelvalue

where VM instance has label labelkey: labelvalue

More details you can find here: https://cloudcustodian.io/docs/filters.html