question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to do a 'not' tag filter?

See original GitHub issue

I am trying to figure out how to write a filter that will match on ‘not equal’ to a value.

For example, this works great to filter out all instances with Environment = “Prod”

policies:
  - name: list-prod-ec2-instances
    resource: ec2
    filters:
      - tag:Environment: "Prod"

But, how do I write a filter that will list all instances where Environment is NOT “Prod”?

I can see from http://capitalone.github.io/cloud-custodian/docs/filters.html that I should be able to use ‘value filters’ for ‘not-equal’, but I don’t know how to write them in the policy together with ‘tag:Environment’.

I tried the following which did not work:

policies:
  - name: list-all-non-prod-ec2-instances
    resource: ec2
    filters:
      - tag:Environment
        value: "Prod"
        op: ne


policies:
  - name: list-all-non-prod-ec2-instances
    resource: ec2
    filters:
      - type: tag
        key: Environment
        value: "Prod"
        op: ne

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kapiltcommented, Sep 14, 2018

short hand form for value is primarily equality, long hand form allows for many other additional operators (not-equal, contains, etc) and value conversions (space/case normalization, date time conversion, etc).

policies:
  - name: list-non-prod-ec2-instances
    resource: ec2
    filters:
        - type: value
          key: "tag:Environment"
          value: "prod"
          value_type: normalize
          op: not-equal
0reactions
rahuldivakarcommented, Mar 31, 2022

how do we check for a tag:value as follows. tag is Owner Value: someone@xyz.com … @xyz.com has to be checked

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tag and Post Content Filtering
Click the account icon , then click Settings. · Scroll down to the "Filtering" section and click the pencil icon to the right...
Read more >
Solved: Filtering for orders with no tag - Shopify Community
Hi you can just paste "NOT tag:*" (without the quotes) to filter only the products/orders that don't have tags. View solution in original...
Read more >
Filter but “Not” Tag ? : r/thingsapp
I was hoping there was an easy way to temporarily "hide" tasks with tags (i.e. "Daily routines") that would allow planning for bigger,...
Read more >
Can I filter backlog in Azure DevOps by Negating a Tag?
Try the Does Not Contain Operator found in Queries. This can be combined with Contains Operator so you can search for certain tags...
Read more >
Filter condition using Tags do not work in Database View ...
Database view reports do not apply filter conditions using Tags. Steps to Reproduce From 'Filter navigator' navigate to Database View 'incident_sla'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found