Skip to content

Commit

Permalink
updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lpizzinidev committed Feb 29, 2024
1 parent 5d19137 commit 8c926f4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@
"VPCPublicSubnet2DefaultRouteB7481BBA",
"VPCPublicSubnet2RouteTableAssociation5A808732"
],
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
}
},
"Parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class TestStack extends cdk.Stack {
parameterGroup: params,
kmsKey,
removalPolicy: cdk.RemovalPolicy.SNAPSHOT,
instanceRemovalPolicy: cdk.RemovalPolicy.RETAIN, // Remember to cleanup after running this test
enablePerformanceInsights: true,
});

Expand Down
38 changes: 32 additions & 6 deletions packages/aws-cdk-lib/aws-docdb/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,13 +1013,26 @@ describe('DatabaseCluster', () => {
},
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
vpc,
instanceRemovalPolicy: cdk.RemovalPolicy.DESTROY,
removalPolicy: cdk.RemovalPolicy.SNAPSHOT,
instanceRemovalPolicy: cdk.RemovalPolicy.RETAIN,
});

// THEN
Template.fromStack(stack).hasResource('AWS::DocDB::DBCluster', {
Properties: {
DBSubnetGroupName: { Ref: 'DatabaseSubnets56F17B9A' },
MasterUsername: 'admin',
MasterUserPassword: 'tooshort',
VpcSecurityGroupIds: [{ 'Fn::GetAtt': ['DatabaseSecurityGroup5C91FDCB', 'GroupId'] }],
},
DeletionPolicy: 'Snapshot',
UpdateReplacePolicy: 'Snapshot',
});

// Associated instance gets specified policy
Template.fromStack(stack).hasResource('AWS::DocDB::DBInstance', {
DeletionPolicy: 'Delete',
UpdateReplacePolicy: 'Delete',
DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
});
});

Expand All @@ -1037,13 +1050,26 @@ describe('DatabaseCluster', () => {
},
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
vpc,
securityGroupRemovalPolicy: cdk.RemovalPolicy.DESTROY,
removalPolicy: cdk.RemovalPolicy.SNAPSHOT,
securityGroupRemovalPolicy: cdk.RemovalPolicy.RETAIN,
});

// THEN
Template.fromStack(stack).hasResource('AWS::DocDB::DBCluster', {
Properties: {
DBSubnetGroupName: { Ref: 'DatabaseSubnets56F17B9A' },
MasterUsername: 'admin',
MasterUserPassword: 'tooshort',
VpcSecurityGroupIds: [{ 'Fn::GetAtt': ['DatabaseSecurityGroup5C91FDCB', 'GroupId'] }],
},
DeletionPolicy: 'Snapshot',
UpdateReplacePolicy: 'Snapshot',
});

// Associated security group gets specified policy
Template.fromStack(stack).hasResource('AWS::EC2::SecurityGroup', {
DeletionPolicy: 'Delete',
UpdateReplacePolicy: 'Delete',
DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
});
});

Expand Down

0 comments on commit 8c926f4

Please sign in to comment.