Created
March 5, 2021 15:24
-
-
Save zxkane/456130a8804c5478442c117efc7fcab0 to your computer and use it in GitHub Desktop.
how set cfn condition to CDK resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const standardPartitionCondition = new CfnCondition(this, 'IsStandardPartition', { | |
expression: Fn.conditionEquals(Aws.PARTITION, 'aws'), | |
}); | |
const dbUser = 'dashboard'; | |
const docDBCluster = new DatabaseCluster(this, 'DashboardDatabase', { | |
masterUser: { | |
username: dbUser, | |
}, | |
storageEncrypted: true, | |
instanceProps: { | |
instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.MEDIUM), | |
vpcSubnets: { | |
subnetType: SubnetType.PRIVATE, | |
}, | |
vpc: props.vpc, | |
}, | |
removalPolicy: RemovalPolicy.DESTROY, | |
}); | |
const secretRotation = docDBCluster.addRotationSingleUser(); | |
(docDBCluster.secret!.node.findAll().filter(c => (c as CfnRotationSchedule).cfnOptions)) | |
.forEach(c => (c as CfnRotationSchedule).cfnOptions.condition = standardPartitionCondition); | |
(secretRotation.node.defaultChild as CfnApplication).cfnOptions.condition = standardPartitionCondition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment