iRobotCorporation / cfn-custom-resource

Collection of tools to enable use of AWS Lambda with CloudFormation
Mozilla Public License 2.0
49 stars 10 forks source link

self.delete() when updating is not needed in the S3Object example #3

Open benbridts opened 6 years ago

benbridts commented 6 years ago

The update method at https://github.com/iRobotCorporation/cfn-custom-resource/blob/master/examples/S3Object.py#L83 checks of the bucket or path changes, and triggers a delete if this happens.

This delete can be removed, because CloudFormation will call the custom resource with a delete event if the physical resource id changes. Calling the put() method will do that.

Removing the delete will also make sure the delete is only triggered when the stack is in UPDATE_COMPLETE_CLEANUP_IN_PROGRESS. Making sure that no data is deleted if a Rollback happens.

benkehoe commented 6 years ago

I didn't realize that, but it makes sense.