How can I delete an Elastic Beanstalk environment that's out of sync with a deleted Amazon RDS database?
Last updated: 2020-04-24
When I try to delete my AWS Elastic Beanstalk environment, I get the following error message in my environment's event stream: "Deleting RDS database named: xxxxxxxxx failed Reason: DBInstance xxxxxxxxx was not found during DescribeDBInstances." Next, I get another error message: "Stack deletion failed: The following resource(s) failed to delete: [AWSEBRDSDatabase]."
How can I resolve these errors and delete my Elastic Beanstalk environment?
You receive this error if you delete an Amazon Relational Database Service (Amazon RDS) database that was created as part of your Elastic Beanstalk environment. The lifecycle of that database is tied to your Elastic Beanstalk environment. If you delete that database from the Amazon RDS console (called an out-of-band deletion), then Elastic Beanstalk gets out of sync with your database resource and can't be deleted.
1. Open the AWS CloudFormation console.
2. In the navigation pane, choose Stacks.
3. In the Stack name column, select the stack for the Elastic Beanstalk environment that you want to delete.
Note: In the Status column for your stack, you should see DELETE_FAILED.
Tip: You can identify your stack by verifying that the environment ID from the Description column in the AWS CloudFormation console matches the environment ID of your Elastic Beanstalk environment.
4. Choose Delete.
5. In the pop-up window, select the AWSEBRDSDatabase check box in the Resources to retain - optional section, and then choose Delete Stack.
Note: AWSEBRDSDatabase is the name of the resource that you want to retain, or skip, when you delete the stack. If you skip this database resource, the stack can delete successfully.
Tip: You can also use the AWS Command Line Interface (AWS CLI) to delete a stack with the following command:
aws cloudformation delete-stack --stack-name YourStackName --retain-resources AWSEBRDSDatabase
6. After the stack changes to DELETE_COMPLETE status, terminate your Elastic Beanstalk environment.