docdb: Cannot create database cluster: cannot find value in secret string
See original GitHub issueI’m unable to create a Database Cluster and keep receiving this error:
Could not find a value associated with JSONKey in SecretString
.
Reproduction Steps
My Database Cluster:
constructor(scope: cdk.Construct, id: string, props: SharedResources) {
super(scope, id, props);
// Create the Database
this.databaseCluster = new DatabaseCluster(this, 'todos-database', {
masterUser: {
username: this.clusterUsername, // NOTE: 'admin' is reserved by DocumentDB
},
instanceType: InstanceType.of(InstanceClass.M3, InstanceSize.MEDIUM),
vpcSubnets: {
subnetType: SubnetType.PRIVATE
},
vpc: props.vpc,
dbClusterName: "todos-database-cluster",
});
}
What did you expect to happen?
A DatabaseCluster to be created with a password generated in secrets manager.
What actually happened?
I am seeing the following error in Cloud Formation:
Could not find a value associated with JSONKey in SecretString
Environment
- CDK CLI Version : 1.97.0 (build c52c2dc)
- Framework Version: 1.97.0
- Node.js Version: v14.16.0
- OS : MacOS 11.2.3
- Language (Version): Typescript 3.8.3
Other
I’ve also attempted to create the secret value manually:
constructor(scope: cdk.Construct, id: string, props: SharedResources) {
super(scope, id, props);
// Database Password
const templatedSecret = new Secret(this, 'TemplatedSecret', {
generateSecretString: {
secretStringTemplate: JSON.stringify({}),
generateStringKey: 'password',
},
});
// Create the Database
this.databaseCluster = new DatabaseCluster(this, 'todos-database', {
masterUser: {
username: this.clusterUsername, // NOTE: 'admin' is reserved by DocumentDB
password: templatedSecret.secretValueFromJson("password")
},
instanceType: InstanceType.of(InstanceClass.M3, InstanceSize.MEDIUM),
vpcSubnets: {
subnetType: SubnetType.PRIVATE,
},
vpc: props.vpc,
dbClusterName: "todos-database-cluster"
});
}
And received this error:
AppStack/todos-database/Resource [AWS::DocDB::DBCluster] is missing required property: masterUsername
/Users/ryan/Source/Repos/infra-demo-lnl/aws/node_modules/@aws-cdk/aws-docdb/lib/docdb.generated.ts:454
inspector.addAttribute("aws:cdk:cloudformation:type", CfnDBClusterParameterGroup.CFN_RESOURCE_TYPE_NAME);
^
While synthesizing AppStack/todos-database/Resource: Cannot read property 'renderTags' of undefined
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
New-DOCDBCluster Cmdlet | AWS Tools for PowerShell
Calls the Amazon DocumentDB (with MongoDB compatibility) CreateDBCluster API operation. ... Cannot be a reserved word for the chosen database engine.
Read more >SecretsManager — Boto3 Docs 1.26.37 documentation
To create a secret, you can provide the secret value to be encrypted in either the SecretString parameter or the SecretBinary parameter, but...
Read more >AWS Secrets Manager in Use for DocumentDB Databases
Secrets Manager service will store MongoDB-compatible database credentials as part of the encrypted secret value (within the "SecretString" ...
Read more >AWS secrets manager, 'A previous rotation isn't complete ...
aws secretsmanager get-secret-value \ --secret-id thefrog ... I just had one secret I could not rotate, kept getting the "A previous ...
Read more >mongorestore — MongoDB Database Tools
mongodump and mongorestore cannot be part of a backup strategy for 4.2+ sharded clusters that have sharded transactions in progress, as backups created...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for providing the repo! I was able to clone it and reproduce the error you got.
Here’s the relevant
cdk synth
output:⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.