How can I delete an Elastic Beanstalk environment that's out of sync with a deleted Amazon RDS database?

2 minute read
0

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." Then, I get another error message: "Stack deletion failed: The following resource(s) failed to delete: [AWSEBRDSDatabase]."

Short Description

This error occurs when an Amazon Relational Database Service (Amazon RDS) database created as part of your Elastic Beanstalk environment is deleted. The lifecycle of the database is tied to your Elastic Beanstalk environment. Deleting the database from the Amazon RDS console (called an out-of-band deletion) can cause Elastic Beanstalk to be out of sync with your database resource. This means that the Elastic Beanstalk environment can't be deleted.

Note: It's a best practice to manage the resources created by Elastic Beanstalk with the Elastic Beanstalk console, Elastic Beanstalk Command Line Interface (EB CLI), or the AWS Command Line Interface (AWS CLI).

Resolution

Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent AWS CLI version.

  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: The Status column for your stack shows DELETE_FAILED. Verify 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 the database resource, then you can delete the stack successfully. To use the AWS CLI to delete a stack, run the following command:

    aws cloudformation delete-stack --stack-name YourStackName --retain-resources AWSEBRDSDatabase --region us-east-1
  6. After the stack changes to DELETE_COMPLETE status, terminate your Elastic Beanstalk environment.
    Important: Enter the correct values for your stack name and AWS Region in the AWS CLI.

Related information

Troubleshooting

AWS OFFICIAL
AWS OFFICIALUpdated 8 months ago