Reputation: 73
I want to terminate my AWS Elastic Beanstalk environment, but I would like to keep a snapshot of the RDS database instance associated with the environment.
I have successfully created a snapshot of the concerned RDS database, but when I go to terminate the Elastic Beanstalk environment, it says that doing so will:
Terminate database-in-question with snapshot.
Does this mean that the snapshot I created will be deleted as well as the database instance? If so, how can I avoid the snapshot being deleted?
Upvotes: 1
Views: 454
Reputation: 4078
Elastic Beanstalk uses CloudFormation in the background to provision your environment. CloudFormation works so that it has a stack that contains all the resources that it has created, and once you delete your Beanstalk environment, said stack is removed. Thus, it will remove all the resources which are part of your stack. You can go to CloudFormation in console, and check it out.
If you created a DB Snapshot manually, it will be outside of the CloudFormation stack, and thus it won't be removed.
However, as part of Beanstalk environment setup, there will be some automated backups of your DB. These are removed, when you terminate your environment.
Here's my test environment stack:
$ aws cloudformation describe-stack-resources --stack-name awseb-e-jjqgv3nwgp-stack --profile=personal
{
"StackResources": [
[...],
{
"StackName": "awseb-e-jjqgv3nwgp-stack",
"StackId": "arn:aws:cloudformation:eu-central-1:[my_account]:stack/awseb-e-jjqgv3nwgp-stack/f21c2e00-ea6d-11eb-9f61-02ad9e7e97f6",
"LogicalResourceId": "AWSEBRDSDBSecurityGroup",
"PhysicalResourceId": "awseb-e-jjqgv3nwgp-stack-AWSEBRDSDBSecurityGroup-1SDABJ60VF7G8",
"ResourceType": "AWS::EC2::SecurityGroup",
"Timestamp": "2021-07-21T21:52:52.931000+00:00",
"ResourceStatus": "CREATE_COMPLETE",
"DriftInformation": {
"StackResourceDriftStatus": "NOT_CHECKED"
}
},
{
"StackName": "awseb-e-jjqgv3nwgp-stack",
"StackId": "arn:aws:cloudformation:eu-central-1:[my_account]:stack/awseb-e-jjqgv3nwgp-stack/f21c2e00-ea6d-11eb-9f61-02ad9e7e97f6",
"LogicalResourceId": "AWSEBRDSDatabase",
"PhysicalResourceId": "aa1v9kyuepq8x1c",
"ResourceType": "AWS::RDS::DBInstance",
"Timestamp": "2021-07-21T21:59:24.817000+00:00",
"ResourceStatus": "CREATE_COMPLETE",
"DriftInformation": {
"StackResourceDriftStatus": "NOT_CHECKED"
}
},
[...]
]
}
Here are my RDS snapshots:
$ aws rds describe-db-snapshots --profile=personal
{
"DBSnapshots": [
{
"DBSnapshotIdentifier": "foobar-snapshot-test",
"DBInstanceIdentifier": "aa1v9kyuepq8x1c",
"SnapshotCreateTime": "2021-07-21T22:09:03.752000+00:00",
"Engine": "mysql",
"AllocatedStorage": 5,
"Status": "available",
"Port": 3306,
"AvailabilityZone": "eu-central-1a",
"VpcId": "vpc-128d5178",
"InstanceCreateTime": "2021-07-21T21:56:51.205000+00:00",
"MasterUsername": "foo",
"EngineVersion": "8.0.23",
"LicenseModel": "general-public-license",
"SnapshotType": "manual",
"OptionGroupName": "default:mysql-8-0",
"PercentProgress": 100,
"StorageType": "standard",
"Encrypted": false,
"DBSnapshotArn": "arn:aws:rds:eu-central-1:[my_account]:snapshot:foobar-snapshot-test",
"IAMDatabaseAuthenticationEnabled": false,
"ProcessorFeatures": [],
"DbiResourceId": "db-PFQFQBRFBELDWUQTONIPRJRVCU",
"TagList": []
},
{
"DBSnapshotIdentifier": "rds:aa1v9kyuepq8x1c-2021-07-21-21-57",
"DBInstanceIdentifier": "aa1v9kyuepq8x1c",
"SnapshotCreateTime": "2021-07-21T21:57:05.277000+00:00",
"Engine": "mysql",
"AllocatedStorage": 5,
"Status": "available",
"Port": 3306,
"AvailabilityZone": "eu-central-1a",
"VpcId": "vpc-128d5178",
"InstanceCreateTime": "2021-07-21T21:56:51.205000+00:00",
"MasterUsername": "foo",
"EngineVersion": "8.0.23",
"LicenseModel": "general-public-license",
"SnapshotType": "automated",
"OptionGroupName": "default:mysql-8-0",
"PercentProgress": 100,
"StorageType": "standard",
"Encrypted": false,
"DBSnapshotArn": "arn:aws:rds:eu-central-1:[my_account]:snapshot:rds:aa1v9kyuepq8x1c-2021-07-21-21-57",
"IAMDatabaseAuthenticationEnabled": false,
"ProcessorFeatures": [],
"DbiResourceId": "db-PFQFQBRFBELDWUQTONIPRJRVCU",
"TagList": []
}
]
}
So, we have one automated snapshot, and one manual.
After deleting the application, the CloudFormation stack was removed, and what's left is the manual snapshot, but the automated one has been deleted:
$ aws rds describe-db-snapshots --profile=personal
{
"DBSnapshots": [
{
"DBSnapshotIdentifier": "foobar-snapshot-test",
"DBInstanceIdentifier": "aa1v9kyuepq8x1c",
"SnapshotCreateTime": "2021-07-21T22:09:03.752000+00:00",
"Engine": "mysql",
"AllocatedStorage": 5,
"Status": "available",
"Port": 3306,
"AvailabilityZone": "eu-central-1a",
"VpcId": "vpc-128d5178",
"InstanceCreateTime": "2021-07-21T21:56:51.205000+00:00",
"MasterUsername": "foo",
"EngineVersion": "8.0.23",
"LicenseModel": "general-public-license",
"SnapshotType": "manual",
"OptionGroupName": "default:mysql-8-0",
"PercentProgress": 100,
"StorageType": "standard",
"Encrypted": false,
"DBSnapshotArn": "arn:aws:rds:eu-central-1:[my_account]:snapshot:foobar-snapshot-test",
"IAMDatabaseAuthenticationEnabled": false,
"ProcessorFeatures": [],
"DbiResourceId": "db-PFQFQBRFBELDWUQTONIPRJRVCU",
"TagList": []
}
]
}
You can always double check your RDS snapshots to be sure you have a manual one there, before terminating anything on Beanstalk.
Upvotes: 1