Skip to content

Commit

Permalink
fix: Remove deprecated CDK usage (#84)
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
kichik authored Oct 31, 2023
1 parent 14835b2 commit 494bb30
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface IRdsSanitizedSnapshotter {
/**
* VPC subnets to use for sanitization task.
*
* @default ec2.SubnetType.PRIVATE_WITH_NAT
* @default ec2.SubnetType.PRIVATE_WITH_EGRESS
*/
readonly sanitizeSubnets?: ec2.SubnetSelection;

Expand Down Expand Up @@ -165,7 +165,7 @@ export class RdsSanitizedSnapshotter extends Construct {
vpcSubnets: props.vpc.selectSubnets(props.dbSubnets ?? { subnetType: ec2.SubnetType.PRIVATE_ISOLATED }),
});

this.subnets = props.sanitizeSubnets ?? { subnetType: ec2.SubnetType.PRIVATE_WITH_NAT };
this.subnets = props.sanitizeSubnets ?? { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS };
this.fargateCluster = props.fargateCluster ?? new ecs.Cluster(this, 'cluster', { vpc: props.vpc });
this.sqlScript = props.script;

Expand Down Expand Up @@ -276,7 +276,9 @@ export class RdsSanitizedSnapshotter extends Construct {

const cleanupTasks = this.cleanup();
this.snapshotter = new stepfunctions.StateMachine(this, 'Director', {
definition: parametersState.next(errorCatcher.addCatch(cleanupTasks, { resultPath: stepfunctions.JsonPath.DISCARD })).next(cleanupTasks),
definitionBody: stepfunctions.DefinitionBody.fromChainable(
parametersState.next(errorCatcher.addCatch(cleanupTasks, { resultPath: stepfunctions.JsonPath.DISCARD })).next(cleanupTasks),
),
});

// needed for creating a snapshot with tags
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "32.0.0",
"files": {
"af64ec05b3dfb7846a43d7aebf55e6ab83ac754192e5c5e8341de0d3e5f4314c": {
"f1e7a5685dfbfebff74232f09740bcac9e3581ba043149f0ec118a950edf5445": {
"source": {
"path": "RDS-Sanitized-Snapshotter-RDS.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "af64ec05b3dfb7846a43d7aebf55e6ab83ac754192e5c5e8341de0d3e5f4314c.json",
"objectKey": "f1e7a5685dfbfebff74232f09740bcac9e3581ba043149f0ec118a950edf5445.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,15 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"MySQLClusterInstance1C435F94D": {
"MySQLClusterwriterD1438EA3": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"DBClusterIdentifier": {
"Ref": "MySQLClusterD5C73C33"
},
"DBInstanceClass": "db.t3.medium",
"DBSubnetGroupName": {
"Ref": "MySQLClusterSubnets30A4ABD4"
},
"Engine": "aurora-mysql"
"Engine": "aurora-mysql",
"PromotionTier": 0
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -524,17 +522,15 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"PostgresClusterInstance1A52CA01E": {
"PostgresClusterwriter527489C6": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"DBClusterIdentifier": {
"Ref": "PostgresCluster5A5B7BE8"
},
"DBInstanceClass": "db.t3.medium",
"DBSubnetGroupName": {
"Ref": "PostgresClusterSubnetsFC10D676"
},
"Engine": "aurora-postgresql"
"Engine": "aurora-postgresql",
"PromotionTier": 0
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down
14 changes: 5 additions & 9 deletions test/default.integ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const vpc = new ec2.Vpc(vpcStack, 'VPC', {
name: 'Private',
},
{
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
name: 'Isolated',
},
],
Expand All @@ -39,10 +39,8 @@ const mysqlDatabaseInstance = new rds.DatabaseInstance(rdsStack, 'MySQL Instance
deleteAutomatedBackups: true,
});
const mysqlDatabaseCluster = new rds.DatabaseCluster(rdsStack, 'MySQL Cluster', {
instanceProps: {
vpc,
},
instances: 1,
vpc,
writer: rds.ClusterInstance.provisioned('writer'),
engine: rds.DatabaseClusterEngine.auroraMysql({
version: AuroraMysqlEngineVersion.of('8.0.mysql_aurora.3.05.0', '8.0'),
}),
Expand All @@ -62,10 +60,8 @@ const postgresDatabaseInstance = new rds.DatabaseInstance(rdsStack, 'Postgres In
deleteAutomatedBackups: true,
});
const postgresDatabaseCluster = new rds.DatabaseCluster(rdsStack, 'Postgres Cluster', {
instanceProps: {
vpc,
},
instances: 1,
vpc,
writer: rds.ClusterInstance.provisioned('writer'),
engine: rds.DatabaseClusterEngine.auroraPostgres({ version: rds.AuroraPostgresEngineVersion.VER_13_4 }),
storageEncryptionKey: sourceKey,
backup: {
Expand Down

0 comments on commit 494bb30

Please sign in to comment.