awslabs / ecr-cleanup-lambda

A script to discover stale ECR images and take action on them with Lambda to help reduce costs.
Other
161 stars 96 forks source link

DRYRUN not working in Lambda #10

Closed mark-burns closed 7 years ago

mark-burns commented 7 years ago

In the Lambda environment I was unable to get the DRYRUN parameter to work. After some debugging I could see that strings were not being converted to boolean. I find that the following code works. I'm not a python expert so there may be a better way to do the same thing.

DRYRUN = bool(str(os.environ.get('DRYRUN', "True")).lower() in ("yes", "true", "t", "1"))

myoung34 commented 7 years ago

I think this is resolved by #9

mark-burns commented 7 years ago

My review of the latest code says otherwise. When running in the Lambda environment I had to modify the code in order to get my Lambda environment variable to convert properly. Since there is no implicit cast to String I had to convert to string and compare against common values for true.

ericdalling commented 7 years ago

I had the same issue. The only way I could get the DRYRUN variable to evaluation as false in the lambda, was to set the DRYRUN environment variable to an empty string ("").

anshrma commented 7 years ago

https://github.com/awslabs/ecr-cleanup-lambda/pull/12