aws-nuke icon indicating copy to clipboard operation
aws-nuke copied to clipboard

Extending aws-nuke to not throw an error when running via lambda utilizing docker images

Open MirTalpur opened this issue 2 years ago • 3 comments

Currently I'm running aws-nuke in lambda utilizing docker images. It runs perfectly fine and finishes the scan/deletion of any nukable resources however, the lambda behaves as if there's a runtime error and the aws-nuke container exits without providing a reason after the run is finished. This is due to the way lambda handles docker images running on lambda without a handler function even though the exit code is 0 it gets treated as if it's exiting incorrectly. I was able to fork this repo and add an environment variable which enables it to run via a lambda handler(note I can also change the logic to pass in a lambda flag as well if deemed the correct approach).

If there's any interest around this I can create a README around how to run this in lambda and create the PR.

Error: Runtime exited without providing a reason
Runtime.ExitError

MirTalpur avatar May 26 '22 06:05 MirTalpur

I'm facing the same issue. Can we have an input from @svenwltr ?

LVSant avatar May 27 '22 13:05 LVSant

Hello. That's a weird behavior of Lambda handling exit codes.

You can either provide a PR based on your fork or add a shell wrapper that modifies the exit code so that Lambda understands it.

svenwltr avatar May 27 '22 15:05 svenwltr

Thanks for the response add the shell wrapper with entrypoint and modifying the exit code didn't seem to work for me in this case. I forced a couple of different scenarios such as exiting without any status code, forcing a status code, even writing something like this at the end the script didn't seem to work RESPONSE="{\"statusCode\": 200, \"body\": \"Hello World\"}" echo $RESPONSE

all of which the lambda still treated as a failure however, when I added a light lambda wrapper it actually ran successfully. I'll create a PR for it and see what everyone thinks

MirTalpur avatar May 27 '22 18:05 MirTalpur