aws-cdk-lib.aws_rds: Cannot set secret to use for master password management on CfnDBInstance #27288
Labels
aws-cdk-lib
Related to the aws-cdk-lib package
bug
This issue is a bug.
needs-cfn
This issue is waiting on changes to CloudFormation before it can be addressed.
Describe the bug
Hi,
The L1 CfnDBInstanceProps class has a MasterUserSecret variable and is a getter/setter. I am trying to specify the secret to use by creating a Secret construct and setting the MasterUserSecret.SecretArn to the Arn of the secret. That all seems to work, and the template shows the secret arn in that field.
However, the CfnDBInstance code seems to be ignoring it, as it is always creating it's own secret key with a format similar to rds!db-5a03a378-08a8-4ccc-98e3-c84e8619a38b.
I was using the L2 class DBInstance, which allowed this and worked fine. But now that i've dropped down to the L1 class, i need the same functionality.
Thanks,
Joe
Expected Behavior
It should have written the username and password to the secret that i gave it.
Current Behavior
It creates its own secret and writes the username and password there.
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.97.0 (build d7cf3be)
Framework Version
No response
Node.js Version
10.1.0
OS
WSL Ubuntu 22.04
Language
.NET
Language Version
7.0
Other information
This is the relevant CF template code that was generated:
`secret:
"PublicApiMySqlInstanceRDSAdminCredentialsC86A16E8": {
"Type": "AWS::SecretsManager::Secret",
"Properties": {
"GenerateSecretString": {
"ExcludeLowercase": false,
"ExcludeNumbers": false,
"ExcludePunctuation": true,
"ExcludeUppercase": false,
"GenerateStringKey": "password",
"IncludeSpace": false,
"PasswordLength": 15,
"RequireEachIncludedType": true,
"SecretStringTemplate": "{"username":"admin"}"
},
"Name": "ct/publicapi/mysql/master/mysqlcredentials"
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain",
"Metadata": {
"aws:cdk:path": "MySqlRDSStack/PublicApiMySqlInstanceRDSAdminCredentials/Resource"
}
},
rds:
"PublicApiMySqlInstance": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"AllocatedStorage": "20",
"AllowMajorVersionUpgrade": false,
"AutoMinorVersionUpgrade": true,
"BackupRetentionPeriod": 1,
"CACertificateIdentifier": "rds-ca-ecc384-g1",
"CertificateRotationRestart": true,
"CopyTagsToSnapshot": true,
"DBInstanceClass": "db.t4g.micro",
"DBSubnetGroupName": "PublicApiRDSSubnetGroup",
"DeleteAutomatedBackups": false,
"DeletionProtection": true,
"EnableCloudwatchLogsExports": [
"error"
],
"EnableIAMDatabaseAuthentication": false,
"Engine": "mysql",
"EngineVersion": "8.0.34",
"ManageMasterUserPassword": true,
"MasterUserSecret": {
"SecretArn": {
"Ref": "PublicApiMySqlInstanceRDSAdminCredentialsC86A16E8"
}
},
"MasterUsername": "admin",
"MultiAZ": false,
"NetworkType": "IPV4",
"Port": "3306",
"PubliclyAccessible": false,
"StorageEncrypted": false,
"StorageType": "gp2",
"VPCSecurityGroups": [
{
"Fn::GetAtt": [
"PublicApiRDSSecurityGroup",
"GroupId"
]
}
]
},
"DependsOn": [
"PublicApiRDSSecurityGroup",
"PublicApiRDSSubnetGroup"
],
"Metadata": {
"aws:cdk:path": "MySqlRDSStack/PublicApiMySqlInstance"
}
}`
The text was updated successfully, but these errors were encountered: