manheim / manheim-c7n-tools

Manheim's Cloud Custodian (c7n) wrapper package, policy generator, runner, and supporting tools.
https://manheim-c7n-tools.readthedocs.io/
Apache License 2.0
45 stars 25 forks source link

Validate step not working in version 1.4.0 #67

Closed ed-rw closed 2 years ago

ed-rw commented 2 years ago

The validate step fails for all polices with an error message of check_deprecations for manheim-c7n-tools version 1.4.0.

It appears that deprecation framework added in cloud custodian version 0.9.13 wants an attribute check_deprecations added to the object passed to the validate function. Without that attribute existing, this line causes an AttributeError that is then reported as making the policy invalid.

This could possibly be viewed as an issue with cloud custodian itself, as the check_deprecations attribute may have been needed to be included as part of an empty config here.

I've fixed the issue by adding check_deprecations="yes" to the instantiation of the config for the ValidateStep here.

For others encountering this issue, you can use this invocation of the docker container to add the necessary attribute to the Config object passed to validate:

docker run -it --rm -v $(pwd):/configs --workdir /configs 
  -e "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" \
  -e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" \
  -e "AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN" \  
  manheim/manheim-c7n-tools:1.4.0 \
  bash -c "sed -i '/conf = Config.empty($/ s/$/check_deprecations=\"yes\",/' /manheim_c7n_tools/manheim_c7n_tools/runner.py; manheim-c7n-runner ..."
jleopold28 commented 2 years ago

This should be resolved by https://github.com/manheim/manheim-c7n-tools/pull/69. The latest release (1.4.1) will have the fix

ed-rw commented 2 years ago

Sweet! I have confirmed that using version 1.4.1 fixes this issue for us. Thanks for the quick responses @jleopold28 and @vincentclee !