Repository: CloudSnorkel/cdk-rds-sanitized-snapshots (language: python)

Issue:
Deprecating API
[WARNING] aws-cdk-lib.aws_ec2.SubnetType#PRIVATE_WITH_NAT is deprecated.
  use `PRIVATE_WITH_EGRESS`
  This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_ec2.SubnetType#PRIVATE_WITH_NAT is deprecated.
  use `PRIVATE_WITH_EGRESS`
  This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_stepfunctions.StateMachineProps#definition is deprecated.
  use definitionBody: DefinitionBody.fromChainable()
  This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_stepfunctions.StateMachineProps#definition is deprecated.
  use definitionBody: DefinitionBody.fromChainable()
  This API will be removed in the next major release.


Discussion / hints:
`SubnetType#PRIVATE_WITH_NAT` was deprecated with [PR #21699](https://github.com/aws/aws-cdk/pull/21699) and CDK [v2.41.0](https://github.com/aws/aws-cdk/releases/tag/v2.41.0). `StateMachineProps#definition` was deprecated with [PR #25932](https://github.com/aws/aws-cdk/pull/25932) and CDK [v2.85.0](https://github.com/aws/aws-cdk/releases/tag/v2.85.0).

We still support CDK v2.0.0. We can't stop using those until we stop supporting older versions of CDK v2.

Fix patch:
diff --git a/API.md b/API.md
index 87e96b2..63d7c4c 100644
--- a/API.md
+++ b/API.md
@@ -393,7 +393,7 @@ public readonly sanitizeSubnets: SubnetSelection;
 ```
 
 - *Type:* aws-cdk-lib.aws_ec2.SubnetSelection
-- *Default:* ec2.SubnetType.PRIVATE_WITH_NAT
+- *Default:* ec2.SubnetType.PRIVATE_WITH_EGRESS
 
 VPC subnets to use for sanitization task.
 
diff --git a/src/index.ts b/src/index.ts
index d775be3..df76efc 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -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;
 
@@ -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;
 
@@ -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


Test patch:
diff --git a/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.assets.json b/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.assets.json
index c80261f..a6357e0 100644
--- a/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.assets.json
+++ b/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.assets.json
@@ -1,7 +1,7 @@
 {
   "version": "32.0.0",
   "files": {
-    "af64ec05b3dfb7846a43d7aebf55e6ab83ac754192e5c5e8341de0d3e5f4314c": {
+    "f1e7a5685dfbfebff74232f09740bcac9e3581ba043149f0ec118a950edf5445": {
       "source": {
         "path": "RDS-Sanitized-Snapshotter-RDS.template.json",
         "packaging": "file"
@@ -9,7 +9,7 @@
       "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}"
         }
       }
diff --git a/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.template.json b/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.template.json
index 740a5de..082742a 100644
--- a/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.template.json
+++ b/test/default.integ.snapshot/RDS-Sanitized-Snapshotter-RDS.template.json
@@ -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"
@@ -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"
diff --git a/test/default.integ.ts b/test/default.integ.ts
index 5de7278..a53e33d 100644
--- a/test/default.integ.ts
+++ b/test/default.integ.ts
@@ -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',
     },
   ],
@@ -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'),
   }),
@@ -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: {