aws-solutions / simple-file-manager-for-amazon-efs

Serverless web application to manage data in your Amazon EFS Filesystem
Apache License 2.0
81 stars 30 forks source link

Rollback/delete IAM Role if Lambda creation fails #126

Closed dreamorosi closed 3 years ago

dreamorosi commented 3 years ago

While onboarding an unmanaged EFS volume that I just created I got an error because I forgot to create a mount target for it. After fixing the issue I went back and ran the onboarding again but this time I got an EntityAlreadyExists error because the IAM Role was leftover from the previous execution.

This happens, I think, because the create_function_role function is called inside the create_function function, see here, but in the except block of the create_function function invocation we are deleting only the access point, not the IAM Role, see here.

I'd recommend trying to delete the IAM Role just created if the onboarding operation fails, if you agree I'm happy to open a PR.

brandold commented 3 years ago

Feel free to open a PR for this if you'd like. Otherwise we'll get it in our sprint backlog. Thanks for reporting!