2 Answers
- Newest
- Most votes
- Most comments
0
Hello.
This is a sample of CDK in TypeScript. If you do the following, it will be automatically registered in Secrets Manager and set as the instance password.
const dbUser: string = 'cdk_test_user';
const dbName: string = 'cdk_test_db';
const rdsCredentials = rds.Credentials.fromGeneratedSecret(dbUser, {
secretName: '/cdk-test/rds/'
});
const rdsInstance = new rds.DatabaseInstance(this, "rds-instance", {
engine: DatabaseInstanceEngine.MYSQL,
credentials: rdsCredentials,
databaseName: dbName,
subnetGroup: subnetGroup,
instanceType: ec2.InstanceType.of(
ec2.InstanceClass.T2,
ec2.InstanceSize.MICRO,
),
vpc: vpc,
publiclyAccessible: false,
securityGroups: [rdsSecurityGroup],
});
0
Actually, this worked.
import { Credentials, DatabaseInstance, } from "aws-cdk-lib/aws-rds";
... const rdsDbInstance = new rds.DatabaseInstance( ... credentials: Credentials.fromSecret(credsSecret), ... )
answered 6 months ago
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 months ago
I want to use an existing credentials. Does this code generate new secrets?
Yes, create a new secret.