Skip to content

How to filter resource by OU tag with c7n-org #9687

Answered by ajkerrigan
jmreicha asked this question in General
Discussion options

You must be logged in to vote

When you use execution conditions, there's an account key that has account details from the c7n-org configuration. So if you want to filter based on tags, you can use the account.tags key in your condition filter. In your case, something like this should work:

conditions:
  - or:
      - type: value
        key: account.tags
        op: contains
        value: "path:/Stage" # <- this is pulled from account.yaml
      - type: value
        key: account_id
        op: in
        value:
          - "111111111111"
          - "222222222222"

c7n-org also provides the ability to select accounts by tag at the command line. So rather than building that condition into your policy, you could run:

c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmreicha
Comment options

Answer selected by jmreicha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants