Replies: 2 comments
-
agreed we should have some better docs here, quick recap fwiw
runtime variable interpolation is to enable better reuse across policies by enabling {region} {account_id}, {now} and a few others to be determined at execution time. alot of the values you see in that file are compatibility with filters/actions that were previously doing some degree of variable interpolation. c7n-org also includes a notion of variables associated to an account, which allows variable interpolation using user defined variables scoped to an account on policy files. |
Beta Was this translation helpful? Give feedback.
-
I hit this recently when trying to merge filters. If examples are still undocumented, could someone add an example here of Edit: I found this on gitter by @jtroberts83 https://gitter.im/cloud-custodian/cloud-custodian?at=59fa4b4432e080696e530931 vars:
common-filters: &age-description-filters
- type: age
days: 7
op: ge
- type: value
key: Description
op: regex
value: ^(Automated,Backup,-?)\w+
policies:
- name: delete-old-snapshots-under-20-gb
resource: ebs-snapshot
filters:
- type: value
key: VolumeSize
op: lt
value: 20
- and: *age-description-filters
actions:
- delete Test: cat policies/iam-attach-default-policy.yml.mod | \
python -c "import sys, yaml; y=yaml.safe_load(sys.stdin.read()); print(y['policies'][0]['filters'][0]['and']);" |
Beta Was this translation helpful? Give feedback.
-
As a new custodian user, I'm trying to understand the usage of variables in policies. There seems to be multiple types of variables.
A non-exhaustive list for a beginner can be:
vars
in a policy yamlNeither of the above ☝️ seem to have documentation around (1) how they are intended to be used, and (2) Examples.
It would be ideal to have a dedicated section within the documentation that describes the different types of variables, their use-cases and examples.
Beta Was this translation helpful? Give feedback.
All reactions