patternpythonMinor
Cross Region Copy of Aurora Snapshots
Viewed 0 times
crosssnapshotsauroraregioncopy
Problem
current_date = str(dt.now().strftime('%Y-%m-%d'))
target_cluster_snapshot_arn= current_date+'_Development_Aurora'
response = TARGET_CLIENT.copy_db_cluster_snapshot(
SourceDBClusterSnapshotIdentifier=source_cluster_snapshot_arn,
TargetDBClusterSnapshotIdentifier=target_cluster_snapshot_arn,
KmsKeyId='arn:aws:kms:us-west-2:xxxxxxx:key/axxxxxx-e326-4df2-8274-73f87ff02f37',
CopyTags=True,
Tags=[
{
'Key': 'Deletion_Date',
'Value': (dt.now() + datetime.timedelta(days=30)).strftime('%Y-%m-%d')
},
],
SourceRegion=SOURCE_REGION
)While using the above code in Python I am getting the error as
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the CopyDBClusterSnapshot operation: Invalid cluster snapshot identifier: 2018-05-22_Development_AuroraBut when i am hardcoding the value in TargerDBClusterSnapshotIdnetifier like below, its working fine
response = TARGET_CLIENT.copy_db_cluster_snapshot(
SourceDBClusterSnapshotIdentifier=source_cluster_snapshot_arn,
TargetDBClusterSnapshotIdentifier='PrashastTest',
KmsKeyId='arn:aws:kms:us-west-2:xxxxxxx:key/xxxxxxb3-e326-4df2-8274-73f87ff02f37',
CopyTags=True,
Tags=[
{
'Key': 'Deletion_Date',
'Value': (dt.now() + datetime.timedelta(days=30)).strftime('%Y-%m-%d')
},
],
SourceRegion=SOURCE_REGION
)Any pointers why is this happening?
Solution
Your proposed snapshot-id is not syntactically valid. When you tried hard-coding the value, you used a valid identifier.
Underscores are not allowed, and the identifier can't begin with a number.
Here are the constraints on snapshot identifiers, from the API Reference:
The identifier of the DB cluster snapshot. This parameter is stored as a lowercase string.
Constraints:
-
Must contain from 1 to 63 letters, numbers, or hyphens.
-
First character must be a letter.
-
Cannot end with a hyphen or contain two consecutive hyphens.
https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBClusterSnapshot.html
Underscores are not allowed, and the identifier can't begin with a number.
Here are the constraints on snapshot identifiers, from the API Reference:
DBClusterSnapshotIdentifierThe identifier of the DB cluster snapshot. This parameter is stored as a lowercase string.
Constraints:
-
Must contain from 1 to 63 letters, numbers, or hyphens.
-
First character must be a letter.
-
Cannot end with a hyphen or contain two consecutive hyphens.
https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBClusterSnapshot.html
Context
StackExchange DevOps Q#4148, answer score: 2
Revisions (0)
No revisions yet.