With Cloudformation you can get the following error:
Exactly one of SnapshotIdentifier and MasterUsername must be specified
You can fix this by specifying one of these values – most likely MasterUsername if you’re here. I think the reason for this is that the backups (snapshots) include (imply) the username.
I.e. this won’t work:
Database:
Type: "AWS::RDS::DBCluster"
Properties:
Engine: "aurora-postgresql"
EngineMode: "serverless"
MasterUserPassword: !Ref DatabasePassword
VpcSecurityGroupIds:
- !Ref DatabaseSecurityGroup
Do this instead:
Database:
Type: "AWS::RDS::DBCluster"
Properties:
Engine: "aurora-postgresql"
EngineMode: "serverless"
MasterUserPassword: !Ref DatabasePassword
MasterUsername: "admin"
VpcSecurityGroupIds:
- !Ref DatabaseSecurityGroup
Hi Gary,
In the first code snippet you’re not specifying the “MasterUsername” – so that should work if you have the “SnapshotIdentifier” below.
I’m facing the same issue where I have the MasterUsername and the SnapshotIdentifier specified. If I want to restore the db from the snapshot I shouldn’t specify the MasterUsername, which is fine because it should be inherited. BUT, if I’m not specifying the username I’m not able to connect to the db afterwards.
Do you have any idea how I can fix this?