I have 2 databases on AWS RDS, one for stage and one for production across 2 accounts. I am trying to copy the data in production to stage every x days. My plan was to make a copy of the most recent automatic backup snapshot in production and share it to the stage account before creating the database in stage using the shared snapshot from production. Everything was going right until I ran into what I believe is a bug but it could easily be that I made a mistake.
When I tried to get the most recent, shared, snapshot with an id of abcd in Terraform with data "aws_db_snapshot", I got no results.
data "aws_db_snapshot" "latest_prod_snapshot" {
db_instance_identifier = "abcd"
snapshot_type = "shared"
include_shared = "true"
most_recent = "true"
}
Then I decided to try out AWS CLI. When I run this...
aws rds describe-db-snapshots --snapshot-type shared --include-shared
... I get this...
{
"DBSnapshots": [
{
"MasterUsername": "root",
"LicenseModel": "general-public-license",
"InstanceCreateTime": "2018-01-13T00:00:00.000Z",
"Engine": "mysql",
"VpcId": "vpc-0000000000000000",
"SourceRegion": "us-east-1",
"AllocatedStorage": 20,
"Status": "available",
"PercentProgress": 100,
"SourceDBSnapshotIdentifier": "arn:aws:rds:us-east-1:000000000000:snapshot:rds:abcd-2020-01-13-00-00",
"DBSnapshotIdentifier": "arn:aws:rds:us-east-1:000000000000:snapshot:rds:abcd-2020-01-13-00-00",
"DBSnapshotArn": "arn:aws:rds:us-east-1:000000000000:snapshot:rds:abcd-2020-01-13-00-00",
"EngineVersion": "5.6.41",
"ProcessorFeatures": [],
"OptionGroupName": "default:mysql-5-6",
"SnapshotCreateTime": "2020-01-13T00:00:00.000Z",
"AvailabilityZone": "us-east-1b",
"StorageType": "gp2",
"Encrypted": false,
"IAMDatabaseAuthenticationEnabled": false,
"DbiResourceId": "db-AAAAAAAAAAAAAAAAAAAAAAAAA",
"SnapshotType": "shared",
"Port": 3306,
"DBInstanceIdentifier": "abcd"
}
]
}
... which is what I expected. Looking at the response, I would expect the db instance id to be abcd but when I run this...
aws rds describe-db-snapshots --snapshot-type shared --include-shared --db-instance-identifier abcd
... or this...
aws rds describe-db-snapshots --snapshot-type shared --include-shared --filters Name=db-instance-id,Values=abcd
... I get this...
{
"DBSnapshots": []
}
... which is not what I would have expected. Is this a bug or am I doing something wrong? I looked through their documentation but I may have missed something.
While we wait for AWS to fix this. Here are some things you can do as workaround:
stage account copy the shared snapshot and use the copy instead of the shared.2.27 works for me
provider "aws" {
version = "2.27.0"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With