AWS CDKのメリット CDK何がいいのかは、YAMLを直接記述するよりも記述量が減る Ssequence: Type: AWS::DynamoDB::Table Properties: TableName: xxxx BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: name KeyType: HASH StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true Muser: Type: AWS::DynamoDB::Table Properties: TableName: yyyy BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: name KeyType: HASH StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true Muser: Type: AWS::DynamoDB::Table Properties: TableName: tttt BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: name KeyType: HASH StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true Muser: Type: AWS::DynamoDB::Table Properties: TableName: zzzz BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: name KeyType: HASH StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true 4つのDynamoDBを作成するYAML for(const name of [”xxxx”, ”yyyy”, “tttt”, ”zzzz”]) new dynamodb.Table(this, 'Sample-table', { tableName: "samble-table", partitionKey: { name: 'id’, type: dynamodb.AttributeType.STRING, }, sortKey: { name: 'name’, type: dynamodb.AttributeType.STRING, }, billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, pointInTimeRecovery: true, timeToLiveAttribute: 'expired', removalPolicy: cdk.RemovalPolicy.DESTROY, }); } 同じ処理をCDKだとこれぐらい