We have a use-case where we want to create new AWS accounts for our AWS Org programmatically. Occasionally, we will decide we no longer need this account, and will want to delete it programmatically. I know AWS provides an API to create an account. However, they don't provide one for account deletion - just for severing the relationship between an AWS Org and an account.
We've come up with 2 options on how to handle this:
- Create a pool of AWS accounts. When we delete one, do so logically, and release it to a pool of AWS accounts we own. When we need a new account, start by re-using the unused ones in our pool. This approach adds complexity to our system.
- Use an automation tool (such as Selenium) to follow the manual process for closing an AWS account. This approach is brittle and subject to changes in the "close AWS account" flow.
Neither approach feels elegant. What's the preferred way to manage AWS accounts that we want to delete programmatically?