I'm setting up an AWS DocumentDB cluster using CloudFormation. I set up a password in Secrets Manager like this:
DbClusterCredentials:
Type: AWS::SecretsManager::Secret
Properties:
Name: …
Description: …
GenerateSecretString:
SecretStringTemplate: '{"username": "admin"}'
GenerateStringKey: "password"
PasswordLength: 100
ExcludeCharacters: '/"@'
Then I reference that in my cluster:
DbCluster:
Type: AWS::DocDB::DBCluster
Properties:
DBClusterIdentifier: …
DBSubnetGroupName: …
…
MasterUsername: !Sub "{{resolve:${DbClusterCredentials}:SecretString:username}}"
MasterUserPassword: !Sub "{{resolve:${DbClusterCredentials}:SecretString:password}}"
…
When I try to deploy this with CloudFormation it rolls back with CREATE_FAILED
for DbCluster
, saying:
Property validation failure: [Length of value for property {/MasterUserPassword} is greater than maximum allowed length {100}, Length of value for property {/MasterUsername} is greater than maximum allowed length {63}]
Um, but I requested a password of exactly 100 characters (which is not greater than the maximum of 100 characters), and the username should be admin
(which is not greater than the maximum allowed length of 63). What am I doing wrong?