Reputation: 3950
I'm working on a AWS CloudFormation management platform which allows users to launch, update and delete stacks on CloudFormation.
When a stack is launched, I create a DB entry to associate it with a Template (collection of resources to be created) and a Customer. Users are able to call and view the latest events happening to their stack i.e. "CREATION_IN_PROGRESS", "CREATION_COMPLETED".
Currently when a stack is deleted, I delete it from the DB immediately, providing no further information to the user aside from "Your stack is being deleted".
The callback that is currently available when executing a deleteStack()
is already returned once the stack deletion is initiated.
I would like to provide more information and events whilst it is being deleted and when the stack is completely deleted, delete it from my DB.
The only way to make this happen is executing a function to check the stacks' existence on a timed interval and once it is gone, delete it from the database.
Am I wrong to assume this, or does anyone reading this have a better idea or implementation?
Any information is welcome.
Upvotes: 3
Views: 1321
Reputation: 19441
Polling yourself used to be the only available option, but the AWS SDK for Java 1.11.25 release introduced the com.amazonaws.waiters
package, see Waiters in the AWS SDK for Java for an overview/introduction.
Note that waiters will still poll under the hood, but they abstract that logic away to offer 'convenience' API methods to wait in a blocking way via run()
or in a callback oriented way via runAsync()
.
Regarding your explicit use case, you should look into AmazonCloudFormationWaiters.stackDeleteComplete()
.
Upvotes: 4