diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets.json new file mode 100644 index 0000000000000..48b88f5f298f1 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/aws-ecs-task-definition-container-version-consistency.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/aws-ecs-task-definition-container-version-consistency.assets.json new file mode 100644 index 0000000000000..02056230d34c2 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/aws-ecs-task-definition-container-version-consistency.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "d4cdd7da3243deb657e43e94ffbd700f5c2b24fbca065b5f78377b1746e91654": { + "source": { + "path": "aws-ecs-task-definition-container-version-consistency.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "d4cdd7da3243deb657e43e94ffbd700f5c2b24fbca065b5f78377b1746e91654.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/aws-ecs-task-definition-container-version-consistency.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/aws-ecs-task-definition-container-version-consistency.template.json new file mode 100644 index 0000000000000..684f80f8a194c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/aws-ecs-task-definition-container-version-consistency.template.json @@ -0,0 +1,81 @@ +{ + "Resources": { + "TaskDefTaskRole1EDB4A67": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "TaskDef54694570": { + "Type": "AWS::ECS::TaskDefinition", + "Properties": { + "ContainerDefinitions": [ + { + "Essential": true, + "Image": "public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest", + "Name": "Container", + "VersionConsistency": "disabled" + } + ], + "Cpu": "256", + "Family": "awsecstaskdefinitioncontainerversionconsistencyTaskDefF7D6E447", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": [ + "FARGATE" + ], + "TaskRoleArn": { + "Fn::GetAtt": [ + "TaskDefTaskRole1EDB4A67", + "Arn" + ] + } + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/integ.json new file mode 100644 index 0000000000000..b23f7f4ee3fb9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "TaskDefinitionContainerRestartPolicy/DefaultTest": { + "stacks": [ + "aws-ecs-task-definition-container-version-consistency" + ], + "assertionStack": "TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert", + "assertionStackName": "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/manifest.json new file mode 100644 index 0000000000000..b3976e0fbc19e --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/manifest.json @@ -0,0 +1,119 @@ +{ + "version": "38.0.1", + "artifacts": { + "aws-ecs-task-definition-container-version-consistency.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-ecs-task-definition-container-version-consistency.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-ecs-task-definition-container-version-consistency": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-ecs-task-definition-container-version-consistency.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/d4cdd7da3243deb657e43e94ffbd700f5c2b24fbca065b5f78377b1746e91654.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-ecs-task-definition-container-version-consistency.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "aws-ecs-task-definition-container-version-consistency.assets" + ], + "metadata": { + "/aws-ecs-task-definition-container-version-consistency/TaskDef/TaskRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDefTaskRole1EDB4A67" + } + ], + "/aws-ecs-task-definition-container-version-consistency/TaskDef/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDef54694570" + } + ], + "/aws-ecs-task-definition-container-version-consistency/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-ecs-task-definition-container-version-consistency/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-ecs-task-definition-container-version-consistency" + }, + "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "TaskDefinitionContainerRestartPolicyDefaultTestDeployAssert2196C660.assets" + ], + "metadata": { + "/TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/tree.json new file mode 100644 index 0000000000000..8d2eac56dae24 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.js.snapshot/tree.json @@ -0,0 +1,196 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-ecs-task-definition-container-version-consistency": { + "id": "aws-ecs-task-definition-container-version-consistency", + "path": "aws-ecs-task-definition-container-version-consistency", + "children": { + "TaskDef": { + "id": "TaskDef", + "path": "aws-ecs-task-definition-container-version-consistency/TaskDef", + "children": { + "TaskRole": { + "id": "TaskRole", + "path": "aws-ecs-task-definition-container-version-consistency/TaskDef/TaskRole", + "children": { + "ImportTaskRole": { + "id": "ImportTaskRole", + "path": "aws-ecs-task-definition-container-version-consistency/TaskDef/TaskRole/ImportTaskRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-ecs-task-definition-container-version-consistency/TaskDef/TaskRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-ecs-task-definition-container-version-consistency/TaskDef/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ECS::TaskDefinition", + "aws:cdk:cloudformation:props": { + "containerDefinitions": [ + { + "essential": true, + "image": "public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest", + "name": "Container", + "versionConsistency": "disabled" + } + ], + "cpu": "256", + "family": "awsecstaskdefinitioncontainerversionconsistencyTaskDefF7D6E447", + "memory": "512", + "networkMode": "awsvpc", + "requiresCompatibilities": [ + "FARGATE" + ], + "taskRoleArn": { + "Fn::GetAtt": [ + "TaskDefTaskRole1EDB4A67", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.CfnTaskDefinition", + "version": "0.0.0" + } + }, + "Container": { + "id": "Container", + "path": "aws-ecs-task-definition-container-version-consistency/TaskDef/Container", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.ContainerDefinition", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.FargateTaskDefinition", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-ecs-task-definition-container-version-consistency/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-ecs-task-definition-container-version-consistency/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "TaskDefinitionContainerRestartPolicy": { + "id": "TaskDefinitionContainerRestartPolicy", + "path": "TaskDefinitionContainerRestartPolicy", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "TaskDefinitionContainerRestartPolicy/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "TaskDefinitionContainerRestartPolicy/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "TaskDefinitionContainerRestartPolicy/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.ts new file mode 100644 index 0000000000000..341d8ca132e76 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.task-definition-container-version-consistency.ts @@ -0,0 +1,17 @@ +import * as cdk from 'aws-cdk-lib'; +import * as ecs from 'aws-cdk-lib/aws-ecs'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'aws-ecs-task-definition-container-version-consistency'); + +const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', {}); + +taskDefinition.addContainer('Container', { + image: ecs.ContainerImage.fromRegistry('public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest'), + versionConsistency: ecs.VersionConsistency.DISABLED, +}); + +new IntegTest(app, 'TaskDefinitionContainerRestartPolicy', { + testCases: [stack], +}); diff --git a/packages/@aws-cdk/aws-msk-alpha/README.md b/packages/@aws-cdk/aws-msk-alpha/README.md index 8155f8829a756..49a00ff89f407 100644 --- a/packages/@aws-cdk/aws-msk-alpha/README.md +++ b/packages/@aws-cdk/aws-msk-alpha/README.md @@ -231,3 +231,24 @@ const cluster = new msk.Cluster(this, 'cluster', { storageMode: msk.StorageMode.TIERED, }); ``` + +## MSK Serverless + +You can also use MSK Serverless by using `ServerlessCluster` class. + +MSK Serverless is a cluster type for Amazon MSK that makes it possible for you to run Apache Kafka without having to manage and scale cluster capacity. + +MSK Serverless requires IAM access control for all clusters. + +For more infomation, see [Use MSK Serverless clusters](https://docs.aws.amazon.com/msk/latest/developerguide/serverless-getting-started.html). + +```ts +declare const vpc: ec2.Vpc; + +const serverlessCluster = new msk.ServerlessCluster(this, 'ServerlessCluster', { + clusterName: 'MyServerlessCluster', + vpcConfigs: [ + { vpc }, + ], +}); +``` diff --git a/packages/@aws-cdk/aws-msk-alpha/awslint.json b/packages/@aws-cdk/aws-msk-alpha/awslint.json index 2923789192b72..17c2a617359b8 100644 --- a/packages/@aws-cdk/aws-msk-alpha/awslint.json +++ b/packages/@aws-cdk/aws-msk-alpha/awslint.json @@ -1,4 +1,5 @@ { "exclude": [ + "props-physical-name:@aws-cdk/aws-msk-alpha.ServerlessClusterProps" ] } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/cluster.ts b/packages/@aws-cdk/aws-msk-alpha/lib/cluster.ts index 2c6ca7647fdb4..29d712d3dc45b 100644 --- a/packages/@aws-cdk/aws-msk-alpha/lib/cluster.ts +++ b/packages/@aws-cdk/aws-msk-alpha/lib/cluster.ts @@ -37,7 +37,7 @@ export interface ICluster extends core.IResource, ec2.IConnectable { /** * A new or imported MSK Cluster. */ -abstract class ClusterBase extends core.Resource implements ICluster { +export abstract class ClusterBase extends core.Resource implements ICluster { public abstract readonly clusterArn: string; public abstract readonly clusterName: string; /** @internal */ diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/index.ts b/packages/@aws-cdk/aws-msk-alpha/lib/index.ts index 674fd3b2e451d..8272507ce9355 100644 --- a/packages/@aws-cdk/aws-msk-alpha/lib/index.ts +++ b/packages/@aws-cdk/aws-msk-alpha/lib/index.ts @@ -1,4 +1,5 @@ export * from './cluster'; export * from './cluster-version'; +export * from './serverless-cluster'; // AWS::MSK CloudFormation Resources: diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/serverless-cluster.ts b/packages/@aws-cdk/aws-msk-alpha/lib/serverless-cluster.ts new file mode 100644 index 0000000000000..66a98e0a200bf --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/lib/serverless-cluster.ts @@ -0,0 +1,153 @@ +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import { Fn, Lazy, Names } from 'aws-cdk-lib'; +import * as constructs from 'constructs'; +import { ClusterBase, ICluster } from '.'; +import { CfnServerlessCluster } from 'aws-cdk-lib/aws-msk'; + +/** + * Properties for a MSK Serverless Cluster + */ +export interface ServerlessClusterProps { + /** + * The physical name of the cluster. + * + * @default - auto generate + */ + readonly clusterName?: string; + + /** + * The configuration of the Amazon VPCs for the cluster. + * You can specify up to 5 VPC configurations. + */ + readonly vpcConfigs: VpcConfig[]; +} + +/** + * The configuration of the Amazon VPCs for the cluster. + */ +export interface VpcConfig { + /** + * Defines the virtual networking environment for this cluster. + * Must have at least 2 subnets in two different AZs. + */ + readonly vpc: ec2.IVpc; + + /** + * The subnets associated with the cluster. + * + * @default - the Vpc default strategy if not specified. + */ + readonly vpcSubnets?: ec2.SubnetSelection; + + /** + * The security groups associated with the cluster. + * You can specify up to 5 security groups. + * + * @default - create new security group + */ + readonly securityGroups?: ec2.ISecurityGroup[]; +} + +/** + * Create a MSK Serverless Cluster. + * + * @resource AWS::MSK::ServerlessCluster + */ +export class ServerlessCluster extends ClusterBase { + /** + * Reference an existing cluster, defined outside of the CDK code, by name. + */ + public static fromClusterArn( + scope: constructs.Construct, + id: string, + clusterArn: string, + ): ICluster { + class Import extends ClusterBase { + public readonly clusterArn = clusterArn; + public readonly clusterName = Fn.select(1, Fn.split('/', clusterArn)); // ['arn:partition:kafka:region:account-id', clusterName, clusterId] + } + + return new Import(scope, id); + } + + public readonly clusterArn: string; + public readonly clusterName: string; + + private _securityGroups: ec2.ISecurityGroup[] = []; + + constructor(scope: constructs.Construct, id: string, props: ServerlessClusterProps) { + super(scope, id, { + physicalName: props.clusterName ?? + Lazy.string({ + produce: () => Names.uniqueResourceName(this, { maxLength: 64 }), + }), + }); + + if (props.vpcConfigs.length < 1 || props.vpcConfigs.length > 5) { + throw Error(`\`vpcConfigs\` must contain between 1 and 5 configurations, got ${props.vpcConfigs.length} configurations.`); + } + + const vpcConfigs = props.vpcConfigs.map((vpcConfig, index) => this._renderVpcConfig(vpcConfig, index)); + + this._connections = new ec2.Connections({ + securityGroups: this._securityGroups, + }); + + /** + * TODO At the time of implementation, MSK Serverless only supports IAM authentication, so it cannot be disabled. + * If it becomes configurable in the future, the property will need to be exposed. + * + * @see https://docs.aws.amazon.com/msk/latest/developerguide/serverless.html + */ + const resource = new CfnServerlessCluster(this, 'Resource', { + clusterName: this.physicalName, + clientAuthentication: { + sasl: { + iam: { + enabled: true, + }, + }, + }, + vpcConfigs, + }); + + this.clusterName = this.getResourceNameAttribute( + Fn.select(1, Fn.split('/', resource.ref)), + ); + this.clusterArn = resource.ref; + } + + /** + * Render Vpc Config property + */ + private _renderVpcConfig(vpcConfig: VpcConfig, index: number): CfnServerlessCluster.VpcConfigProperty { + const subnetSelection = vpcConfig.vpc.selectSubnets(vpcConfig.vpcSubnets); + + if (subnetSelection.subnets.length < 2) { + throw Error( + `Cluster requires at least 2 subnets, got ${subnetSelection.subnets.length} subnet.`, + ); + } + + let securityGroups: ec2.ISecurityGroup[] = []; + + if (vpcConfig.securityGroups) { + if (vpcConfig.securityGroups.length < 1 || vpcConfig.securityGroups.length > 5) { + throw Error(`\`securityGroups\` must contain between 1 and 5 elements, got ${vpcConfig.securityGroups.length} elements.`); + } + securityGroups = vpcConfig.securityGroups; + } else { + securityGroups.push(new ec2.SecurityGroup(this, `SecurityGroup-${index}`, { + description: 'MSK Serverless security group', + vpc: vpcConfig.vpc, + })); + } + + this._securityGroups.push(...securityGroups); + + return { + subnetIds: subnetSelection.subnets.map((subnet) => subnet.subnetId), + securityGroups: securityGroups?.map((securityGroup) => securityGroup.securityGroupId), + }; + } +} diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/cdk.out b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/cdk.out new file mode 100644 index 0000000000000..91e1a8b9901d5 --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"39.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/integ.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/integ.json new file mode 100644 index 0000000000000..83c26b86dc826 --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "39.0.0", + "testCases": { + "msk-serverless-integ/DefaultTest": { + "stacks": [ + "msk-serverless-stack" + ], + "assertionStack": "msk-serverless-integ/DefaultTest/DeployAssert", + "assertionStackName": "mskserverlessintegDefaultTestDeployAssertDD46F007" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/manifest.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/manifest.json new file mode 100644 index 0000000000000..19bf33ff4e77d --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/manifest.json @@ -0,0 +1,401 @@ +{ + "version": "39.0.0", + "artifacts": { + "msk-serverless-stack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "msk-serverless-stack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "msk-serverless-stack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "msk-serverless-stack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3fe96e39425f97feda99213d01b2d2cc26bae96d4178c3cff77274254846f2dc.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "msk-serverless-stack.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "msk-serverless-stack.assets" + ], + "metadata": { + "/msk-serverless-stack/VPC/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCB9E5F0B4" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1SubnetB4246D30" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableFEE4B781" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableAssociation0B0896DC" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1DefaultRoute91CEF279" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1EIP6AD938E8" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1NATGatewayE0556630" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2Subnet74179F39" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTable6F1A15F1" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTableAssociation5A808732" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2DefaultRouteB7481BBA" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2EIP4947BC00" + } + ], + "/msk-serverless-stack/VPC/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2NATGateway3C070193" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1Subnet8BCA10E0" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableBE8A6027" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableAssociation347902D1" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1DefaultRouteAE1D6490" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTable0A19E10E" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTableAssociation0C73D413" + } + ], + "/msk-serverless-stack/VPC/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2DefaultRouteF4F5CFD2" + } + ], + "/msk-serverless-stack/VPC/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCIGWB7E252D3" + } + ], + "/msk-serverless-stack/VPC/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCVPCGW99B986DC" + } + ], + "/msk-serverless-stack/AnotherVPC/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPC6F66D700" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet1Subnet2C5E9FEA" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet1RouteTable99F4404A" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet1RouteTableAssociation2362026E" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet1DefaultRouteA00BB689" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet1EIPEF7D42CC" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet1NATGatewayCF4D3D2F" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet2Subnet15F04B8B" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet2RouteTableFE644F5F" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet2RouteTableAssociationC009DC2F" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet2DefaultRoute5306D480" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet2EIP19D14E7D" + } + ], + "/msk-serverless-stack/AnotherVPC/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPublicSubnet2NATGatewayC40A97B0" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet1Subnet15DC540C" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet1RouteTable3DABBDAF" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet1RouteTableAssociation013B68AD" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet1DefaultRoute2361ECAB" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet2Subnet418BD755" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet2RouteTableA7D262FC" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet2RouteTableAssociation5A9F546E" + } + ], + "/msk-serverless-stack/AnotherVPC/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCPrivateSubnet2DefaultRouteE03FE5F7" + } + ], + "/msk-serverless-stack/AnotherVPC/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCIGW5E5649EB" + } + ], + "/msk-serverless-stack/AnotherVPC/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "AnotherVPCVPCGW86198180" + } + ], + "/msk-serverless-stack/SecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "SecurityGroupDD263621" + } + ], + "/msk-serverless-stack/ServerlessCluster/SecurityGroup-0/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ServerlessClusterSecurityGroup0535E269F" + } + ], + "/msk-serverless-stack/ServerlessCluster/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ServerlessClusterD09D5D78" + } + ], + "/msk-serverless-stack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/msk-serverless-stack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "msk-serverless-stack" + }, + "mskserverlessintegDefaultTestDeployAssertDD46F007.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "mskserverlessintegDefaultTestDeployAssertDD46F007.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "mskserverlessintegDefaultTestDeployAssertDD46F007": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "mskserverlessintegDefaultTestDeployAssertDD46F007.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "mskserverlessintegDefaultTestDeployAssertDD46F007.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "mskserverlessintegDefaultTestDeployAssertDD46F007.assets" + ], + "metadata": { + "/msk-serverless-integ/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/msk-serverless-integ/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "msk-serverless-integ/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/msk-serverless-stack.assets.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/msk-serverless-stack.assets.json new file mode 100644 index 0000000000000..a9090ef6c4062 --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/msk-serverless-stack.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "3fe96e39425f97feda99213d01b2d2cc26bae96d4178c3cff77274254846f2dc": { + "source": { + "path": "msk-serverless-stack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "3fe96e39425f97feda99213d01b2d2cc26bae96d4178c3cff77274254846f2dc.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/msk-serverless-stack.template.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/msk-serverless-stack.template.json new file mode 100644 index 0000000000000..6a1f8f4be718a --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/msk-serverless-stack.template.json @@ -0,0 +1,905 @@ +{ + "Resources": { + "VPCB9E5F0B4": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC" + } + ] + } + }, + "VPCPublicSubnet1SubnetB4246D30": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet1RouteTableFEE4B781": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "VPCPublicSubnet1DefaultRoute91CEF279": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + } + }, + "DependsOn": [ + "VPCVPCGW99B986DC" + ] + }, + "VPCPublicSubnet1EIP6AD938E8": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ] + } + }, + "VPCPublicSubnet1NATGatewayE0556630": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC" + ] + }, + "VPCPublicSubnet2Subnet74179F39": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet2RouteTable6F1A15F1": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + } + }, + "DependsOn": [ + "VPCVPCGW99B986DC" + ] + }, + "VPCPublicSubnet2EIP4947BC00": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ] + } + }, + "VPCPublicSubnet2NATGateway3C070193": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732" + ] + }, + "VPCPrivateSubnet1Subnet8BCA10E0": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet1RouteTableBE8A6027": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "SubnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + } + } + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet2RouteTable0A19E10E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "SubnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + } + } + }, + "VPCIGWB7E252D3": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/VPC" + } + ] + } + }, + "VPCVPCGW99B986DC": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "AnotherVPC6F66D700": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC" + } + ] + } + }, + "AnotherVPCPublicSubnet1Subnet2C5E9FEA": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPublicSubnet1RouteTable99F4404A": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPublicSubnet1RouteTableAssociation2362026E": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "AnotherVPCPublicSubnet1RouteTable99F4404A" + }, + "SubnetId": { + "Ref": "AnotherVPCPublicSubnet1Subnet2C5E9FEA" + } + } + }, + "AnotherVPCPublicSubnet1DefaultRouteA00BB689": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "AnotherVPCIGW5E5649EB" + }, + "RouteTableId": { + "Ref": "AnotherVPCPublicSubnet1RouteTable99F4404A" + } + }, + "DependsOn": [ + "AnotherVPCVPCGW86198180" + ] + }, + "AnotherVPCPublicSubnet1EIPEF7D42CC": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ] + } + }, + "AnotherVPCPublicSubnet1NATGatewayCF4D3D2F": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "AnotherVPCPublicSubnet1EIPEF7D42CC", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "AnotherVPCPublicSubnet1Subnet2C5E9FEA" + }, + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "AnotherVPCPublicSubnet1DefaultRouteA00BB689", + "AnotherVPCPublicSubnet1RouteTableAssociation2362026E" + ] + }, + "AnotherVPCPublicSubnet2Subnet15F04B8B": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPublicSubnet2RouteTableFE644F5F": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPublicSubnet2RouteTableAssociationC009DC2F": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "AnotherVPCPublicSubnet2RouteTableFE644F5F" + }, + "SubnetId": { + "Ref": "AnotherVPCPublicSubnet2Subnet15F04B8B" + } + } + }, + "AnotherVPCPublicSubnet2DefaultRoute5306D480": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "AnotherVPCIGW5E5649EB" + }, + "RouteTableId": { + "Ref": "AnotherVPCPublicSubnet2RouteTableFE644F5F" + } + }, + "DependsOn": [ + "AnotherVPCVPCGW86198180" + ] + }, + "AnotherVPCPublicSubnet2EIP19D14E7D": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ] + } + }, + "AnotherVPCPublicSubnet2NATGatewayC40A97B0": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "AnotherVPCPublicSubnet2EIP19D14E7D", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "AnotherVPCPublicSubnet2Subnet15F04B8B" + }, + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "AnotherVPCPublicSubnet2DefaultRoute5306D480", + "AnotherVPCPublicSubnet2RouteTableAssociationC009DC2F" + ] + }, + "AnotherVPCPrivateSubnet1Subnet15DC540C": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPrivateSubnet1RouteTable3DABBDAF": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPrivateSubnet1RouteTableAssociation013B68AD": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "AnotherVPCPrivateSubnet1RouteTable3DABBDAF" + }, + "SubnetId": { + "Ref": "AnotherVPCPrivateSubnet1Subnet15DC540C" + } + } + }, + "AnotherVPCPrivateSubnet1DefaultRoute2361ECAB": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "AnotherVPCPublicSubnet1NATGatewayCF4D3D2F" + }, + "RouteTableId": { + "Ref": "AnotherVPCPrivateSubnet1RouteTable3DABBDAF" + } + } + }, + "AnotherVPCPrivateSubnet2Subnet418BD755": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPrivateSubnet2RouteTableA7D262FC": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "AnotherVPCPrivateSubnet2RouteTableAssociation5A9F546E": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "AnotherVPCPrivateSubnet2RouteTableA7D262FC" + }, + "SubnetId": { + "Ref": "AnotherVPCPrivateSubnet2Subnet418BD755" + } + } + }, + "AnotherVPCPrivateSubnet2DefaultRouteE03FE5F7": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "AnotherVPCPublicSubnet2NATGatewayC40A97B0" + }, + "RouteTableId": { + "Ref": "AnotherVPCPrivateSubnet2RouteTableA7D262FC" + } + } + }, + "AnotherVPCIGW5E5649EB": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "msk-serverless-stack/AnotherVPC" + } + ] + } + }, + "AnotherVPCVPCGW86198180": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "AnotherVPCIGW5E5649EB" + }, + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "SecurityGroupDD263621": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "msk-serverless-stack/SecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "255.255.255.255/32", + "Description": "Disallow all traffic", + "FromPort": 252, + "IpProtocol": "icmp", + "ToPort": 86 + } + ], + "VpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "ServerlessClusterSecurityGroup0535E269F": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "MSK Serverless security group", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "ServerlessClusterD09D5D78": { + "Type": "AWS::MSK::ServerlessCluster", + "Properties": { + "ClientAuthentication": { + "Sasl": { + "Iam": { + "Enabled": true + } + } + }, + "ClusterName": "my-serverless-cluster", + "VpcConfigs": [ + { + "SecurityGroups": [ + { + "Fn::GetAtt": [ + "ServerlessClusterSecurityGroup0535E269F", + "GroupId" + ] + } + ], + "SubnetIds": [ + { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + }, + { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ] + }, + { + "SecurityGroups": [ + { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + } + ], + "SubnetIds": [ + { + "Ref": "AnotherVPCPrivateSubnet1Subnet15DC540C" + }, + { + "Ref": "AnotherVPCPrivateSubnet2Subnet418BD755" + } + ] + } + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/mskserverlessintegDefaultTestDeployAssertDD46F007.assets.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/mskserverlessintegDefaultTestDeployAssertDD46F007.assets.json new file mode 100644 index 0000000000000..42e1beffaf0b8 --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/mskserverlessintegDefaultTestDeployAssertDD46F007.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "mskserverlessintegDefaultTestDeployAssertDD46F007.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/mskserverlessintegDefaultTestDeployAssertDD46F007.template.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/mskserverlessintegDefaultTestDeployAssertDD46F007.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/mskserverlessintegDefaultTestDeployAssertDD46F007.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/tree.json b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/tree.json new file mode 100644 index 0000000000000..af0b00a4cb9df --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.js.snapshot/tree.json @@ -0,0 +1,1526 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "msk-serverless-stack": { + "id": "msk-serverless-stack", + "path": "msk-serverless-stack", + "children": { + "VPC": { + "id": "VPC", + "path": "msk-serverless-stack/VPC", + "children": { + "Resource": { + "id": "Resource", + "path": "msk-serverless-stack/VPC/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "msk-serverless-stack/VPC/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/VPC/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/VPC/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/VPC/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/VPC/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/VPC/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "msk-serverless-stack/VPC/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "msk-serverless-stack/VPC/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "msk-serverless-stack/VPC/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/VPC/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/VPC/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/VPC/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/VPC/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/VPC/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "msk-serverless-stack/VPC/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "msk-serverless-stack/VPC/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "msk-serverless-stack/VPC/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/VPC/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/VPC/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/VPC/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/VPC/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/VPC/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "msk-serverless-stack/VPC/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/VPC/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/VPC/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/VPC/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/VPC/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/VPC/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "msk-serverless-stack/VPC/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/VPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "msk-serverless-stack/VPC/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" + } + }, + "AnotherVPC": { + "id": "AnotherVPC", + "path": "msk-serverless-stack/AnotherVPC", + "children": { + "Resource": { + "id": "Resource", + "path": "msk-serverless-stack/AnotherVPC/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "AnotherVPCPublicSubnet1RouteTable99F4404A" + }, + "subnetId": { + "Ref": "AnotherVPCPublicSubnet1Subnet2C5E9FEA" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "AnotherVPCIGW5E5649EB" + }, + "routeTableId": { + "Ref": "AnotherVPCPublicSubnet1RouteTable99F4404A" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "AnotherVPCPublicSubnet1EIPEF7D42CC", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "AnotherVPCPublicSubnet1Subnet2C5E9FEA" + }, + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "AnotherVPCPublicSubnet2RouteTableFE644F5F" + }, + "subnetId": { + "Ref": "AnotherVPCPublicSubnet2Subnet15F04B8B" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "AnotherVPCIGW5E5649EB" + }, + "routeTableId": { + "Ref": "AnotherVPCPublicSubnet2RouteTableFE644F5F" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "msk-serverless-stack/AnotherVPC/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "AnotherVPCPublicSubnet2EIP19D14E7D", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "AnotherVPCPublicSubnet2Subnet15F04B8B" + }, + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "AnotherVPCPrivateSubnet1RouteTable3DABBDAF" + }, + "subnetId": { + "Ref": "AnotherVPCPrivateSubnet1Subnet15DC540C" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "AnotherVPCPublicSubnet1NATGatewayCF4D3D2F" + }, + "routeTableId": { + "Ref": "AnotherVPCPrivateSubnet1RouteTable3DABBDAF" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "AnotherVPCPrivateSubnet2RouteTableA7D262FC" + }, + "subnetId": { + "Ref": "AnotherVPCPrivateSubnet2Subnet418BD755" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "msk-serverless-stack/AnotherVPC/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "AnotherVPCPublicSubnet2NATGatewayC40A97B0" + }, + "routeTableId": { + "Ref": "AnotherVPCPrivateSubnet2RouteTableA7D262FC" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "msk-serverless-stack/AnotherVPC/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "msk-serverless-stack/AnotherVPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "msk-serverless-stack/AnotherVPC/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "AnotherVPCIGW5E5649EB" + }, + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" + } + }, + "SecurityGroup": { + "id": "SecurityGroup", + "path": "msk-serverless-stack/SecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "msk-serverless-stack/SecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "msk-serverless-stack/SecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "255.255.255.255/32", + "description": "Disallow all traffic", + "ipProtocol": "icmp", + "fromPort": 252, + "toPort": 86 + } + ], + "vpcId": { + "Ref": "AnotherVPC6F66D700" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "ServerlessCluster": { + "id": "ServerlessCluster", + "path": "msk-serverless-stack/ServerlessCluster", + "children": { + "SecurityGroup-0": { + "id": "SecurityGroup-0", + "path": "msk-serverless-stack/ServerlessCluster/SecurityGroup-0", + "children": { + "Resource": { + "id": "Resource", + "path": "msk-serverless-stack/ServerlessCluster/SecurityGroup-0/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "MSK Serverless security group", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "msk-serverless-stack/ServerlessCluster/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::MSK::ServerlessCluster", + "aws:cdk:cloudformation:props": { + "clientAuthentication": { + "sasl": { + "iam": { + "enabled": true + } + } + }, + "clusterName": "my-serverless-cluster", + "vpcConfigs": [ + { + "subnetIds": [ + { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + }, + { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ], + "securityGroups": [ + { + "Fn::GetAtt": [ + "ServerlessClusterSecurityGroup0535E269F", + "GroupId" + ] + } + ] + }, + { + "subnetIds": [ + { + "Ref": "AnotherVPCPrivateSubnet1Subnet15DC540C" + }, + { + "Ref": "AnotherVPCPrivateSubnet2Subnet418BD755" + } + ], + "securityGroups": [ + { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + } + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_msk.CfnServerlessCluster", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "msk-serverless-stack/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "msk-serverless-stack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "msk-serverless-integ": { + "id": "msk-serverless-integ", + "path": "msk-serverless-integ", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "msk-serverless-integ/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "msk-serverless-integ/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "msk-serverless-integ/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "msk-serverless-integ/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "msk-serverless-integ/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.ts b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.ts new file mode 100644 index 0000000000000..36cf635fc526a --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/integ.serverless-cluster.ts @@ -0,0 +1,36 @@ +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import * as cdk from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import * as msk from '../lib'; + +const app = new cdk.App(); + +class ServelessStack extends cdk.Stack { + constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { + super(scope, id, props); + const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false }); + const anotherVpc = new ec2.Vpc(this, 'AnotherVPC', { maxAzs: 2, restrictDefaultSecurityGroup: false }); + const securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { + vpc: anotherVpc, + allowAllOutbound: false, + }); + + new msk.ServerlessCluster(this, 'ServerlessCluster', { + clusterName: 'my-serverless-cluster', + vpcConfigs: [ + { vpc }, + { + vpc: anotherVpc, + vpcSubnets: anotherVpc.selectSubnets({ subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }), + securityGroups: [securityGroup], + }, + ], + }); + } +} + +const stack = new ServelessStack(app, 'msk-serverless-stack'); + +new IntegTest(app, 'msk-serverless-integ', { + testCases: [stack], +}); diff --git a/packages/@aws-cdk/aws-msk-alpha/test/serverless-cluster.test.ts b/packages/@aws-cdk/aws-msk-alpha/test/serverless-cluster.test.ts new file mode 100644 index 0000000000000..5d574deb9a44f --- /dev/null +++ b/packages/@aws-cdk/aws-msk-alpha/test/serverless-cluster.test.ts @@ -0,0 +1,208 @@ +import { Template } from 'aws-cdk-lib/assertions'; +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import * as core from 'aws-cdk-lib'; +import * as msk from '../lib'; + +describe('MSK Serverless Cluster', () => { + let stack: core.Stack; + let vpc: ec2.IVpc; + + beforeEach(() => { + stack = new core.Stack(); + vpc = new ec2.Vpc(stack, 'Vpc'); + }); + + test('creates a serverless cluster with minimal properties', () => { + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + vpcConfigs: [{ + vpc, + }], + }); + + Template.fromStack(stack).hasResourceProperties('AWS::MSK::ServerlessCluster', { + ClusterName: 'ServerlessCluster', + ClientAuthentication: { + Sasl: { + Iam: { + Enabled: true, + }, + }, + }, + VpcConfigs: [{ + SubnetIds: [ + { Ref: 'VpcPrivateSubnet1Subnet536B997A' }, + { Ref: 'VpcPrivateSubnet2Subnet3788AAA1' }, + ], + SecurityGroups: [ + { 'Fn::GetAtt': ['ServerlessClusterSecurityGroup0535E269F', 'GroupId'] }, + ], + }], + }); + }); + + test('creates a serverless cluster with multiple VPC configurations', () => { + const anotherVpc = new ec2.Vpc(stack, 'AnotherVpc'); + const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup', { + vpc, + }); + const anotherSecurityGroup1 = new ec2.SecurityGroup(stack, 'AnotherSecurityGroup1', { + vpc: anotherVpc, + }); + const anotherSecurityGroup2 = new ec2.SecurityGroup(stack, 'AnotherSecurityGroup2', { + vpc: anotherVpc, + }); + + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + clusterName: 'MyServerlessCluster', + vpcConfigs: [ + { + vpc, + vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }), + securityGroups: [securityGroup], + }, + { + vpc: anotherVpc, + securityGroups: [anotherSecurityGroup1, anotherSecurityGroup2], + }, + ], + }); + + Template.fromStack(stack).hasResourceProperties('AWS::MSK::ServerlessCluster', { + ClusterName: 'MyServerlessCluster', + ClientAuthentication: { + Sasl: { + Iam: { + Enabled: true, + }, + }, + }, + VpcConfigs: [ + { + SubnetIds: [ + { Ref: 'VpcPublicSubnet1Subnet5C2D37C4' }, + { Ref: 'VpcPublicSubnet2Subnet691E08A3' }, + ], + SecurityGroups: [ + stack.resolve(securityGroup.securityGroupId), + ], + }, + { + SubnetIds: [ + { Ref: 'AnotherVpcPrivateSubnet1SubnetA8BEDDE4' }, + { Ref: 'AnotherVpcPrivateSubnet2Subnet66A0F53A' }, + ], + SecurityGroups: [ + stack.resolve(anotherSecurityGroup1.securityGroupId), + stack.resolve(anotherSecurityGroup2.securityGroupId), + ], + }, + ], + }); + }); + + test('throws error when VPC configurations are empty', () => { + expect(() => + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + vpcConfigs: [], + }), + ).toThrow('`vpcConfigs` must contain between 1 and 5 configurations, got 0 configurations.'); + }); + + test('throws error when VPC configurations exceed the limit of 5', () => { + const vpc1 = new ec2.Vpc(stack, 'Vpc1'); + const vpc2 = new ec2.Vpc(stack, 'Vpc2'); + const vpc3 = new ec2.Vpc(stack, 'Vpc3'); + const vpc4 = new ec2.Vpc(stack, 'Vpc4'); + const vpc5 = new ec2.Vpc(stack, 'Vpc5'); + const vpc6 = new ec2.Vpc(stack, 'Vpc6'); + + expect(() => + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + vpcConfigs: [ + { vpc: vpc1 }, + { vpc: vpc2 }, + { vpc: vpc3 }, + { vpc: vpc4 }, + { vpc: vpc5 }, + { vpc: vpc6 }, + ], + }), + ).toThrow('`vpcConfigs` must contain between 1 and 5 configurations, got 6 configurations.'); + }); + + test('throws an error when `securityGroups` in `vpcConfig` is empty', () => { + expect(() => + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + vpcConfigs: [ + { + vpc, + securityGroups: [ + ], + }, + ], + }), + ).toThrow('`securityGroups` must contain between 1 and 5 elements, got 0 elements.'); + }); + + test('throws error when a single `vpcConfig` has more than 5 security groups', () => { + const securityGroup1 = new ec2.SecurityGroup(stack, 'SecurityGroup1', { + vpc, + }); + const securityGroup2 = new ec2.SecurityGroup(stack, 'SecurityGroup2', { + vpc, + }); + const securityGroup3 = new ec2.SecurityGroup(stack, 'SecurityGroup3', { + vpc, + }); + const securityGroup4 = new ec2.SecurityGroup(stack, 'SecurityGroup4', { + vpc, + }); + const securityGroup5 = new ec2.SecurityGroup(stack, 'SecurityGroup5', { + vpc, + }); + const securityGroup6 = new ec2.SecurityGroup(stack, 'SecurityGroup6', { + vpc, + }); + + expect(() => + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + vpcConfigs: [ + { + vpc, + securityGroups: [ + securityGroup1, + securityGroup2, + securityGroup3, + securityGroup4, + securityGroup5, + securityGroup6, + ], + }, + ], + }), + ).toThrow('`securityGroups` must contain between 1 and 5 elements, got 6 elements.'); + }); + + test('throws error when a single VPC configuration has fewer than 2 subnets', () => { + const vpc1Az = new ec2.Vpc(stack, 'VPC1Az', { + maxAzs: 1, + }); + + expect(() => + new msk.ServerlessCluster(stack, 'ServerlessCluster', { + vpcConfigs: [ + { vpc: vpc1Az }, + ], + }), + ).toThrow('Cluster requires at least 2 subnets, got 1 subnet.'); + }); + + test('imports an existing serverless cluster by ARN', () => { + const clusterArn = 'arn:aws:kafka:us-east-1:111111111111:cluster/MyServerlessCluster/11111111-1111-1111-1111-111111111111-1'; + + const serverlessCluster = msk.ServerlessCluster.fromClusterArn(stack, 'ServerlessCluster', clusterArn); + + expect(serverlessCluster.clusterName).toEqual('MyServerlessCluster'); + expect(serverlessCluster.clusterArn).toEqual(clusterArn); + }); +}); diff --git a/packages/aws-cdk-lib/aws-ecs/README.md b/packages/aws-cdk-lib/aws-ecs/README.md index 2df6c107b1d53..21edfcb866a42 100644 --- a/packages/aws-cdk-lib/aws-ecs/README.md +++ b/packages/aws-cdk-lib/aws-ecs/README.md @@ -1922,6 +1922,20 @@ taskDefinition.addContainer('TheContainer', { }); ``` +## Disable service container image version consistency + +You can disable the +[container image "version consistency"](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html#deployment-container-image-stability) +feature of ECS service deployments on a per-container basis. + +```ts +const taskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef'); +taskDefinition.addContainer('TheContainer', { + image: ecs.ContainerImage.fromRegistry('example-image'), + versionConsistency: ecs.VersionConsistency.DISABLED, +}); +``` + ## Specify a container ulimit You can specify a container `ulimits` by specifying them in the `ulimits` option while adding the container diff --git a/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts b/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts index 1e2442ebc0e94..fd4688b545dde 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts @@ -220,6 +220,7 @@ export interface TaskDefinitionProps extends CommonTaskDefinitionProps { * Not supported in Fargate. * * @default - No inference accelerators. + * @deprecated ECS TaskDefinition's inferenceAccelerator is EOL since April 2024 */ readonly inferenceAccelerators?: InferenceAccelerator[]; @@ -724,6 +725,7 @@ export class TaskDefinition extends TaskDefinitionBase { /** * Adds an inference accelerator to the task definition. + * @deprecated ECS TaskDefinition's inferenceAccelerator is EOL since April 2024 */ public addInferenceAccelerator(inferenceAccelerator: InferenceAccelerator) { if (isFargateCompatible(this.compatibility)) { diff --git a/packages/aws-cdk-lib/aws-ecs/lib/container-definition.ts b/packages/aws-cdk-lib/aws-ecs/lib/container-definition.ts index 3d1fc9f1ac317..50453bf1d6264 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/container-definition.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/container-definition.ts @@ -321,6 +321,19 @@ export interface ContainerDefinitionOptions { */ readonly user?: string; + /** + * Specifies whether Amazon ECS will resolve the container image tag provided + * in the container definition to an image digest. + * + * If you set the value for a container as disabled, Amazon ECS will + * not resolve the provided container image tag to a digest and will use the + * original image URI specified in the container definition for deployment. + * + * @default VersionConsistency.DISABLED if `image` is a CDK asset, VersionConsistency.ENABLED otherwise + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-containerdefinition.html#cfn-ecs-taskdefinition-containerdefinition-versionconsistency + */ + readonly versionConsistency?: VersionConsistency; + /** * The working directory in which to run commands inside the container. * @@ -548,6 +561,8 @@ export class ContainerDefinition extends Construct { private _namedPorts: Map; + private versionConsistency?: VersionConsistency; + /** * Constructs a new instance of the ContainerDefinition class. */ @@ -569,6 +584,8 @@ export class ContainerDefinition extends Construct { this._namedPorts = new Map(); + this.versionConsistency = props.versionConsistency; + if (props.logging) { this.logDriverConfig = props.logging.bind(this, this); } @@ -876,6 +893,23 @@ export class ContainerDefinition extends Construct { return defaultPortMapping.containerPort; } + /** + * Allows disabling version consistency if the user did not specify a value. + * + * Intended for CDK asset images, as asset images are tagged based upon a hash + * of image inputs, meaning the image won't change if the tag didn't change, + * making version consistency for such containers a waste of time. Literally, + * as version consistency can only be achieved by slowing down deployments. + * + * @see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html#deployment-container-image-stability + * @internal + */ + public _defaultDisableVersionConsistency() { + if (!this.versionConsistency) { + this.versionConsistency = VersionConsistency.DISABLED; + } + } + /** * Render this container definition to a CloudFormation object * @@ -910,6 +944,7 @@ export class ContainerDefinition extends Construct { stopTimeout: this.props.stopTimeout && this.props.stopTimeout.toSeconds(), ulimits: cdk.Lazy.any({ produce: () => this.ulimits.map(renderUlimit) }, { omitEmptyArray: true }), user: this.props.user, + versionConsistency: this.versionConsistency, volumesFrom: cdk.Lazy.any({ produce: () => this.volumesFrom.map(renderVolumeFrom) }, { omitEmptyArray: true }), workingDirectory: this.props.workingDirectory, logConfiguration: this.logDriverConfig, @@ -1498,6 +1533,22 @@ function renderMountPoint(mp: MountPoint): CfnTaskDefinition.MountPointProperty }; } +/** + * State of the container version consistency feature. + * + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-containerdefinition.html#cfn-ecs-taskdefinition-containerdefinition-versionconsistency + */ +export enum VersionConsistency { + /** + * The version consistency feature is enabled for this container. + */ + ENABLED = 'enabled', + /** + * The version consistency feature is disabled for this container. + */ + DISABLED = 'disabled', +} + /** * The details on a data volume from another container in the same task definition. */ diff --git a/packages/aws-cdk-lib/aws-ecs/lib/container-image.ts b/packages/aws-cdk-lib/aws-ecs/lib/container-image.ts index d6030a98d16cc..bbade45119359 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/container-image.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/container-image.ts @@ -45,6 +45,7 @@ export abstract class ContainerImage { public static fromDockerImageAsset(asset: DockerImageAsset): ContainerImage { return { bind(_scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig { + containerDefinition._defaultDisableVersionConsistency?.(); asset.repository.grantPull(containerDefinition.taskDefinition.obtainExecutionRole()); return { imageName: asset.imageUri, diff --git a/packages/aws-cdk-lib/aws-ecs/lib/images/asset-image.ts b/packages/aws-cdk-lib/aws-ecs/lib/images/asset-image.ts index 07eef9ca04773..150db07ab5aa2 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/images/asset-image.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/images/asset-image.ts @@ -23,6 +23,7 @@ export class AssetImage extends ContainerImage { } public bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig { + containerDefinition._defaultDisableVersionConsistency?.(); const asset = new DockerImageAsset(scope, 'AssetImage', { directory: this.directory, ...this.props, diff --git a/packages/aws-cdk-lib/aws-ecs/test/container-definition.test.ts b/packages/aws-cdk-lib/aws-ecs/test/container-definition.test.ts index ea1906823fd1f..e9d05b277eb87 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/container-definition.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/container-definition.test.ts @@ -2955,4 +2955,108 @@ describe('container definition', () => { }); }).toThrow(/The restartAttemptPeriod must be between 60 seconds and 1800 seconds, got 59 seconds/); }); + + test('can specify version consistency', () => { + // GIVEN + const stack = new cdk.Stack(); + const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef'); + + // WHEN + new ecs.ContainerDefinition(stack, 'Container', { + image: ecs.ContainerImage.fromRegistry('/aws/aws-example-app'), + taskDefinition, + memoryLimitMiB: 2048, + versionConsistency: ecs.VersionConsistency.ENABLED, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + ContainerDefinitions: [ + { + Image: '/aws/aws-example-app', + Name: 'Container', + Memory: 2048, + VersionConsistency: 'enabled', + }, + ], + }); + }); + + test('version consistency will not be set if not specified', () => { + // GIVEN + const stack = new cdk.Stack(); + const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef'); + + // WHEN + new ecs.ContainerDefinition(stack, 'Container', { + image: ecs.ContainerImage.fromRegistry('/aws/aws-example-app'), + taskDefinition, + memoryLimitMiB: 2048, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + ContainerDefinitions: [ + { + Image: '/aws/aws-example-app', + Name: 'Container', + Memory: 2048, + VersionConsistency: Match.absent(), + }, + ], + }); + }); + + test('version consistency can be default disabled if appropriate', () => { + // GIVEN + const stack = new cdk.Stack(); + const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef'); + + // WHEN + const container = new ecs.ContainerDefinition(stack, 'Container', { + image: ecs.ContainerImage.fromRegistry('/aws/aws-example-app'), + taskDefinition, + memoryLimitMiB: 2048, + }); + container._defaultDisableVersionConsistency(); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + ContainerDefinitions: [ + { + Image: '/aws/aws-example-app', + Name: 'Container', + Memory: 2048, + VersionConsistency: 'disabled', + }, + ], + }); + }); + + test('version consistency default disable does not override props', () => { + // GIVEN + const stack = new cdk.Stack(); + const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef'); + + // WHEN + const container = new ecs.ContainerDefinition(stack, 'Container', { + image: ecs.ContainerImage.fromRegistry('/aws/aws-example-app'), + taskDefinition, + memoryLimitMiB: 2048, + versionConsistency: ecs.VersionConsistency.ENABLED, + }); + container._defaultDisableVersionConsistency(); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + ContainerDefinitions: [ + { + Image: '/aws/aws-example-app', + Name: 'Container', + Memory: 2048, + VersionConsistency: 'enabled', + }, + ], + }); + }); });