Handling updates, deletions, and failures of CRs
Our CR can create a database for us. But try to guess what will happen if you attempt to delete this resource or stack from CloudFormation.
It will fail to delete. Why? Because our CR function runs only one function, create_db
, it doesn't matter which request type is received by CloudFormation. Exactly the same will happen if we try to update our database.
We need to add support for updates and deletes for our Lambda. We will start with the delete functionality, because what we will do is make our custom resource immutable.
This means that whenever we change our custom database, the old one will always be deleted. Sounds scary? Don't worry: unfortunately, this is the default behavior for custom resources. Moreover, some AWS resources are also replaced (for example, a new resource is created while the old one is being deleted), even if nothing major is being changed.
Deleting resource
We will cover the delete...