Fix error: “Exactly one of SnapshotIdentifier and MasterUsername must be specified”

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