konokenj.cdk-api-mcp-server 0.52.0__py3-none-any.whl → 0.53.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. cdk_api_mcp_server/__about__.py +1 -1
  2. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-lambda-go-alpha/README.md +102 -4
  3. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/README.md +0 -1
  4. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/README.md +65 -4
  5. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-big-response.ts +13 -6
  6. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cloudfront.ts +20 -18
  7. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-nested-stack-source.ts +7 -1
  8. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-source.ts +6 -1
  9. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-ssm-source.ts +7 -1
  10. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-data.ts +83 -62
  11. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-deployed-bucket.ts +10 -4
  12. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-large-file.ts +20 -12
  13. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-loggroup.ts +7 -2
  14. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-efs.ts +77 -0
  15. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-empty.ts +69 -0
  16. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-multiple.ts +89 -0
  17. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-single.ts +77 -0
  18. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-signcontent.ts +11 -7
  19. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution-with-destination-key.ts +15 -8
  20. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution-with-role.ts +29 -14
  21. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution.ts +16 -8
  22. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-basic.ts +65 -0
  23. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-config.ts +66 -0
  24. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-custom-subnets.ts +66 -0
  25. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-efs.ts +66 -0
  26. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-security-groups.ts +72 -0
  27. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-subnet-selection.ts +70 -0
  28. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment.ts +47 -69
  29. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.sm-jsonpath-with-distributed-map-jsonata.ts +105 -0
  30. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +2 -2
  31. {konokenj_cdk_api_mcp_server-0.52.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/METADATA +2 -2
  32. {konokenj_cdk_api_mcp_server-0.52.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/RECORD +35 -24
  33. {konokenj_cdk_api_mcp_server-0.52.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/WHEEL +0 -0
  34. {konokenj_cdk_api_mcp_server-0.52.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/entry_points.txt +0 -0
  35. {konokenj_cdk_api_mcp_server-0.52.0.dist-info → konokenj_cdk_api_mcp_server-0.53.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,18 +1,26 @@
1
1
  import * as path from 'path';
2
2
  import * as lambda from 'aws-cdk-lib/aws-lambda';
3
3
  import * as cdk from 'aws-cdk-lib';
4
- import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
4
+ import * as integ from '@aws-cdk/integ-tests-alpha';
5
+ import { ExpectedResult } from '@aws-cdk/integ-tests-alpha';
5
6
  import { Bucket } from 'aws-cdk-lib/aws-s3';
6
7
  import { DeployTimeSubstitutedFile } from 'aws-cdk-lib/aws-s3-deployment';
8
+ import { Construct } from 'constructs';
7
9
  import { STANDARD_NODEJS_RUNTIME } from '../../config';
8
10
 
9
- class Test extends cdk.Stack {
11
+ /**
12
+ * Integration test for DeployTimeSubstitutedFile:
13
+ * - Tests deploy-time string substitution in template files
14
+ * - Validates that token values (like Lambda ARN) are properly substituted
15
+ * - Tests both token and static string substitutions
16
+ */
17
+ class TestBucketDeploymentSubstitution extends cdk.Stack {
10
18
  public readonly bucketName: String;
11
19
  public readonly objectKey: String;
12
20
  public readonly lambdaArn: String;
13
21
 
14
- constructor(scope: cdk.App, id: string) {
15
- super(scope, id);
22
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
23
+ super(scope, id, props);
16
24
 
17
25
  const hello = new lambda.Function(this, 'Hello', {
18
26
  runtime: STANDARD_NODEJS_RUNTIME,
@@ -21,7 +29,7 @@ class Test extends cdk.Stack {
21
29
  });
22
30
 
23
31
  const bucket = new Bucket(this, 'substitution-bucket');
24
- const file = new DeployTimeSubstitutedFile(this, 'Deployment', {
32
+ const file = new DeployTimeSubstitutedFile(this, 'DeployWithSubstitution', {
25
33
  source: path.join(__dirname, 'sample-file.yaml'),
26
34
  destinationBucket: bucket,
27
35
  substitutions: {
@@ -42,12 +50,12 @@ const app = new cdk.App({
42
50
  },
43
51
  });
44
52
 
45
- const testCase = new Test(app, 'test-s3-deploy-substitution');
46
- const integ = new IntegTest(app, 'deploy-time-substitution-integ-test', {
53
+ const testCase = new TestBucketDeploymentSubstitution(app, 'test-bucket-deployment-substitution');
54
+ const integTest = new integ.IntegTest(app, 'integ-test-bucket-deployment-substitution', {
47
55
  testCases: [testCase],
48
56
  });
49
57
 
50
- const apiCall = integ.assertions.awsApiCall('S3', 'getObject', {
58
+ const apiCall = integTest.assertions.awsApiCall('S3', 'getObject', {
51
59
  Bucket: testCase.bucketName,
52
60
  Key: testCase.objectKey,
53
61
  });
@@ -0,0 +1,65 @@
1
+ import * as path from 'path';
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as cdk from 'aws-cdk-lib';
5
+ import * as integ from '@aws-cdk/integ-tests-alpha';
6
+ import { Construct } from 'constructs';
7
+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
8
+
9
+ /**
10
+ * Integration test for bucket deployment with basic VPC configuration:
11
+ * - Lambda function runs in VPC with isolated subnets
12
+ * - Uses S3 Gateway endpoint to access S3 without NAT Gateway
13
+ */
14
+ class TestBucketDeploymentVpcBasic extends cdk.Stack {
15
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16
+ super(scope, id, props);
17
+
18
+ // Basic VPC with isolated subnets - no NAT Gateway or Elastic IP needed
19
+ // Add S3 VPC Gateway endpoint for Lambda to access S3 without internet
20
+ const vpc = new ec2.Vpc(this, 'BasicVpc', {
21
+ restrictDefaultSecurityGroup: false,
22
+ natGateways: 0,
23
+ subnetConfiguration: [
24
+ {
25
+ cidrMask: 24,
26
+ name: 'Isolated',
27
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
28
+ },
29
+ ],
30
+ });
31
+
32
+ // Add S3 Gateway endpoint so Lambda can access S3 without NAT Gateway
33
+ vpc.addGatewayEndpoint('S3Endpoint', {
34
+ service: ec2.GatewayVpcEndpointAwsService.S3,
35
+ });
36
+
37
+ const bucket = new s3.Bucket(this, 'Destination', {
38
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
39
+ autoDeleteObjects: true,
40
+ });
41
+
42
+ new s3deploy.BucketDeployment(this, 'DeployWithBasicVpc', {
43
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
44
+ destinationBucket: bucket,
45
+ destinationKeyPrefix: 'basic-vpc/',
46
+ vpc: vpc,
47
+ retainOnDelete: false,
48
+ });
49
+ }
50
+ }
51
+
52
+ const app = new cdk.App({
53
+ postCliContext: {
54
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
55
+ },
56
+ });
57
+
58
+ const testCase = new TestBucketDeploymentVpcBasic(app, 'test-bucket-deployment-vpc-basic');
59
+
60
+ new integ.IntegTest(app, 'integ-test-bucket-deployment-vpc-basic', {
61
+ testCases: [testCase],
62
+ diffAssets: false,
63
+ });
64
+
65
+ app.synth();
@@ -0,0 +1,66 @@
1
+ import * as path from 'path';
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as cdk from 'aws-cdk-lib';
5
+ import * as integ from '@aws-cdk/integ-tests-alpha';
6
+ import { Construct } from 'constructs';
7
+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
8
+
9
+ /**
10
+ * Integration test for bucket deployment with VPC and Lambda configuration:
11
+ * - Lambda function runs in VPC with custom memory limit
12
+ * - Tests that Lambda configuration options work with VPC deployments
13
+ */
14
+ class TestBucketDeploymentVpcConfig extends cdk.Stack {
15
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16
+ super(scope, id, props);
17
+
18
+ // VPC with memory and timeout configuration
19
+ // Use isolated subnets with S3 VPC endpoint - no NAT Gateway or Elastic IP needed
20
+ const vpc = new ec2.Vpc(this, 'ConfigVpc', {
21
+ restrictDefaultSecurityGroup: false,
22
+ natGateways: 0,
23
+ subnetConfiguration: [
24
+ {
25
+ cidrMask: 24,
26
+ name: 'Isolated',
27
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
28
+ },
29
+ ],
30
+ });
31
+
32
+ // Add S3 Gateway endpoint so Lambda can access S3 without NAT Gateway
33
+ vpc.addGatewayEndpoint('S3Endpoint', {
34
+ service: ec2.GatewayVpcEndpointAwsService.S3,
35
+ });
36
+
37
+ const bucket = new s3.Bucket(this, 'Destination', {
38
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
39
+ autoDeleteObjects: true,
40
+ });
41
+
42
+ new s3deploy.BucketDeployment(this, 'DeployWithVpcAndConfig', {
43
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
44
+ destinationBucket: bucket,
45
+ destinationKeyPrefix: 'config-vpc/',
46
+ vpc: vpc,
47
+ memoryLimit: 1024,
48
+ retainOnDelete: false,
49
+ });
50
+ }
51
+ }
52
+
53
+ const app = new cdk.App({
54
+ postCliContext: {
55
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
56
+ },
57
+ });
58
+
59
+ const testCase = new TestBucketDeploymentVpcConfig(app, 'test-bucket-deployment-vpc-config');
60
+
61
+ new integ.IntegTest(app, 'integ-test-bucket-deployment-vpc-config', {
62
+ testCases: [testCase],
63
+ diffAssets: false,
64
+ });
65
+
66
+ app.synth();
@@ -0,0 +1,66 @@
1
+ import * as path from 'path';
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as cdk from 'aws-cdk-lib';
5
+ import * as integ from '@aws-cdk/integ-tests-alpha';
6
+ import { Construct } from 'constructs';
7
+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
8
+
9
+ /**
10
+ * Integration test for bucket deployment with VPC and custom subnet configuration:
11
+ * - Lambda function runs in VPC with custom maxAzs and subnet configuration
12
+ * - Tests that custom VPC configurations work with bucket deployments
13
+ */
14
+ class TestBucketDeploymentVpcCustomSubnets extends cdk.Stack {
15
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16
+ super(scope, id, props);
17
+
18
+ // VPC with custom subnet configuration
19
+ // Use isolated subnets with S3 VPC endpoint - no NAT Gateway or Elastic IP needed
20
+ const vpc = new ec2.Vpc(this, 'CustomVpc', {
21
+ restrictDefaultSecurityGroup: false,
22
+ maxAzs: 2,
23
+ natGateways: 0,
24
+ subnetConfiguration: [
25
+ {
26
+ cidrMask: 24,
27
+ name: 'Isolated',
28
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
29
+ },
30
+ ],
31
+ });
32
+
33
+ // Add S3 Gateway endpoint so Lambda can access S3 without NAT Gateway
34
+ vpc.addGatewayEndpoint('S3Endpoint', {
35
+ service: ec2.GatewayVpcEndpointAwsService.S3,
36
+ });
37
+
38
+ const bucket = new s3.Bucket(this, 'Destination', {
39
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
40
+ autoDeleteObjects: true,
41
+ });
42
+
43
+ new s3deploy.BucketDeployment(this, 'DeployWithCustomVpc', {
44
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
45
+ destinationBucket: bucket,
46
+ destinationKeyPrefix: 'custom-vpc/',
47
+ vpc: vpc,
48
+ retainOnDelete: false,
49
+ });
50
+ }
51
+ }
52
+
53
+ const app = new cdk.App({
54
+ postCliContext: {
55
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
56
+ },
57
+ });
58
+
59
+ const testCase = new TestBucketDeploymentVpcCustomSubnets(app, 'test-bucket-deployment-vpc-custom-subnets');
60
+
61
+ new integ.IntegTest(app, 'integ-test-bucket-deployment-vpc-custom-subnets', {
62
+ testCases: [testCase],
63
+ diffAssets: false,
64
+ });
65
+
66
+ app.synth();
@@ -0,0 +1,66 @@
1
+ import * as path from 'path';
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as cdk from 'aws-cdk-lib';
5
+ import * as integ from '@aws-cdk/integ-tests-alpha';
6
+ import { Construct } from 'constructs';
7
+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
8
+
9
+ /**
10
+ * Integration test for bucket deployment with VPC and EFS storage:
11
+ * - Lambda function runs in VPC with EFS filesystem mounted
12
+ * - Tests useEfs flag for large file deployments requiring persistent storage
13
+ */
14
+ class TestBucketDeploymentVpcEfs extends cdk.Stack {
15
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16
+ super(scope, id, props);
17
+
18
+ // VPC with EFS storage enabled
19
+ // Use isolated subnets with S3 VPC endpoint - no NAT Gateway or Elastic IP needed
20
+ const vpc = new ec2.Vpc(this, 'EfsVpc', {
21
+ restrictDefaultSecurityGroup: false,
22
+ natGateways: 0,
23
+ subnetConfiguration: [
24
+ {
25
+ cidrMask: 24,
26
+ name: 'Isolated',
27
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
28
+ },
29
+ ],
30
+ });
31
+
32
+ // Add S3 Gateway endpoint so Lambda can access S3 without NAT Gateway
33
+ vpc.addGatewayEndpoint('S3Endpoint', {
34
+ service: ec2.GatewayVpcEndpointAwsService.S3,
35
+ });
36
+
37
+ const bucket = new s3.Bucket(this, 'Destination', {
38
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
39
+ autoDeleteObjects: true,
40
+ });
41
+
42
+ new s3deploy.BucketDeployment(this, 'DeployWithEfsVpc', {
43
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
44
+ destinationBucket: bucket,
45
+ destinationKeyPrefix: 'efs-vpc/',
46
+ vpc: vpc,
47
+ useEfs: true,
48
+ retainOnDelete: false,
49
+ });
50
+ }
51
+ }
52
+
53
+ const app = new cdk.App({
54
+ postCliContext: {
55
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
56
+ },
57
+ });
58
+
59
+ const testCase = new TestBucketDeploymentVpcEfs(app, 'test-bucket-deployment-vpc-efs');
60
+
61
+ new integ.IntegTest(app, 'integ-test-bucket-deployment-vpc-efs', {
62
+ testCases: [testCase],
63
+ diffAssets: false,
64
+ });
65
+
66
+ app.synth();
@@ -0,0 +1,72 @@
1
+ import * as path from 'path';
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as cdk from 'aws-cdk-lib';
5
+ import * as integ from '@aws-cdk/integ-tests-alpha';
6
+ import { Construct } from 'constructs';
7
+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
8
+
9
+ /**
10
+ * Integration test for bucket deployment with VPC and custom security groups:
11
+ * - Lambda function runs in VPC with custom security group
12
+ * - Security group allows all outbound traffic for S3 access
13
+ */
14
+ class TestBucketDeploymentVpcSecurityGroups extends cdk.Stack {
15
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16
+ super(scope, id, props);
17
+
18
+ // VPC with specific security groups
19
+ // Use isolated subnets with S3 VPC endpoint - no NAT Gateway or Elastic IP needed
20
+ const vpc = new ec2.Vpc(this, 'SgVpc', {
21
+ restrictDefaultSecurityGroup: false,
22
+ natGateways: 0,
23
+ subnetConfiguration: [
24
+ {
25
+ cidrMask: 24,
26
+ name: 'Isolated',
27
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
28
+ },
29
+ ],
30
+ });
31
+
32
+ // Add S3 Gateway endpoint so Lambda can access S3 without NAT Gateway
33
+ vpc.addGatewayEndpoint('S3Endpoint', {
34
+ service: ec2.GatewayVpcEndpointAwsService.S3,
35
+ });
36
+
37
+ const securityGroup = new ec2.SecurityGroup(this, 'CustomSecurityGroup', {
38
+ vpc: vpc,
39
+ description: 'Custom security group for bucket deployment',
40
+ allowAllOutbound: true,
41
+ });
42
+
43
+ const bucket = new s3.Bucket(this, 'Destination', {
44
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
45
+ autoDeleteObjects: true,
46
+ });
47
+
48
+ new s3deploy.BucketDeployment(this, 'DeployWithVpcAndSecurityGroup', {
49
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
50
+ destinationBucket: bucket,
51
+ destinationKeyPrefix: 'sg-vpc/',
52
+ vpc: vpc,
53
+ securityGroups: [securityGroup],
54
+ retainOnDelete: false,
55
+ });
56
+ }
57
+ }
58
+
59
+ const app = new cdk.App({
60
+ postCliContext: {
61
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
62
+ },
63
+ });
64
+
65
+ const testCase = new TestBucketDeploymentVpcSecurityGroups(app, 'test-bucket-deployment-vpc-security-groups');
66
+
67
+ new integ.IntegTest(app, 'integ-test-bucket-deployment-vpc-security-groups', {
68
+ testCases: [testCase],
69
+ diffAssets: false,
70
+ });
71
+
72
+ app.synth();
@@ -0,0 +1,70 @@
1
+ import * as path from 'path';
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import * as cdk from 'aws-cdk-lib';
5
+ import * as integ from '@aws-cdk/integ-tests-alpha';
6
+ import { Construct } from 'constructs';
7
+ import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
8
+
9
+ /**
10
+ * Integration test for bucket deployment with VPC and explicit subnet selection:
11
+ * - Lambda function runs in VPC with explicit subnet type selection
12
+ * - Tests vpcSubnets property for controlling which subnets Lambda uses
13
+ */
14
+ class TestBucketDeploymentVpcSubnetSelection extends cdk.Stack {
15
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16
+ super(scope, id, props);
17
+
18
+ // VPC with specific subnets
19
+ // Use isolated subnets with S3 VPC endpoint - no NAT Gateway or Elastic IP needed
20
+ // Use a different CIDR to avoid conflicts with existing stacks
21
+ const vpc = new ec2.Vpc(this, 'SubnetVpc', {
22
+ restrictDefaultSecurityGroup: false,
23
+ natGateways: 0,
24
+ ipAddresses: ec2.IpAddresses.cidr('10.1.0.0/16'),
25
+ subnetConfiguration: [
26
+ {
27
+ cidrMask: 24,
28
+ name: 'Isolated',
29
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
30
+ },
31
+ ],
32
+ });
33
+
34
+ // Add S3 Gateway endpoint so Lambda can access S3 without NAT Gateway
35
+ vpc.addGatewayEndpoint('S3Endpoint', {
36
+ service: ec2.GatewayVpcEndpointAwsService.S3,
37
+ });
38
+
39
+ const bucket = new s3.Bucket(this, 'Destination', {
40
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
41
+ autoDeleteObjects: true,
42
+ });
43
+
44
+ new s3deploy.BucketDeployment(this, 'DeployWithVpcAndSubnets', {
45
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
46
+ destinationBucket: bucket,
47
+ destinationKeyPrefix: 'subnet-vpc/',
48
+ vpc: vpc,
49
+ vpcSubnets: {
50
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
51
+ },
52
+ retainOnDelete: false,
53
+ });
54
+ }
55
+ }
56
+
57
+ const app = new cdk.App({
58
+ postCliContext: {
59
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
60
+ },
61
+ });
62
+
63
+ const testCase = new TestBucketDeploymentVpcSubnetSelection(app, 'test-bucket-deployment-vpc-subnet-selection');
64
+
65
+ new integ.IntegTest(app, 'integ-test-bucket-deployment-vpc-subnet-selection', {
66
+ testCases: [testCase],
67
+ diffAssets: false,
68
+ });
69
+
70
+ app.synth();
@@ -1,5 +1,4 @@
1
1
  import * as path from 'path';
2
- import * as ec2 from 'aws-cdk-lib/aws-ec2';
3
2
  import * as s3 from 'aws-cdk-lib/aws-s3';
4
3
  import * as cdk from 'aws-cdk-lib';
5
4
  import * as integ from '@aws-cdk/integ-tests-alpha';
@@ -7,115 +6,93 @@ import { Match } from '@aws-cdk/integ-tests-alpha';
7
6
  import { Construct } from 'constructs';
8
7
  import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
9
8
 
9
+ /**
10
+ * Integration test for core bucket deployment features:
11
+ * - Basic deployment functionality
12
+ * - Prune behavior (deleting files not in source)
13
+ * - Exclude filters
14
+ * - Extract behavior (extracting vs keeping zip files)
15
+ * - addSource() method for dynamically adding sources
16
+ * - objectKeys output property and outputObjectKeys flag
17
+ */
10
18
  class TestBucketDeployment extends cdk.Stack {
11
- public readonly bucket5: s3.IBucket;
19
+ public readonly bucketWithAddSource: s3.IBucket;
12
20
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
13
21
  super(scope, id, props);
14
22
 
15
- const destinationBucket = new s3.Bucket(this, 'Destination', {
16
- websiteIndexDocument: 'index.html',
17
- publicReadAccess: false,
23
+ const commonBucketProps = {
18
24
  removalPolicy: cdk.RemovalPolicy.DESTROY,
19
25
  autoDeleteObjects: true, // needed for integration test cleanup
20
- });
26
+ };
21
27
 
22
- new s3deploy.BucketDeployment(this, 'DeployMe', {
23
- sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
24
- destinationBucket,
25
- retainOnDelete: false, // default is true, which will block the integration test cleanup
28
+ const destinationBucket = new s3.Bucket(this, 'Destination', {
29
+ ...commonBucketProps,
26
30
  });
27
31
 
28
- new s3deploy.BucketDeployment(this, 'DeployMeWithEfsStorage', {
32
+ // Test basic deployment functionality
33
+ new s3deploy.BucketDeployment(this, 'DeployWithBasic', {
29
34
  sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
30
35
  destinationBucket,
31
- destinationKeyPrefix: 'efs/',
32
- useEfs: true,
33
- vpc: new ec2.Vpc(this, 'InlineVpc', { restrictDefaultSecurityGroup: false }),
34
- retainOnDelete: false, // default is true, which will block the integration test cleanup
35
- });
36
-
37
- const bucket2 = new s3.Bucket(this, 'Destination2', {
38
- removalPolicy: cdk.RemovalPolicy.DESTROY,
39
- autoDeleteObjects: true, // needed for integration test cleanup
40
- });
41
-
42
- new s3deploy.BucketDeployment(this, 'DeployWithPrefix', {
43
- sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
44
- destinationBucket: bucket2,
45
- destinationKeyPrefix: 'deploy/here/',
46
- retainOnDelete: false, // default is true, which will block the integration test cleanup
47
- });
48
-
49
- const bucket3 = new s3.Bucket(this, 'Destination3', {
50
- removalPolicy: cdk.RemovalPolicy.DESTROY,
51
- autoDeleteObjects: true, // needed for integration test cleanup
52
- });
53
-
54
- new s3deploy.BucketDeployment(this, 'DeployWithMetadata', {
55
- sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
56
- destinationBucket: bucket3,
57
- retainOnDelete: false, // default is true, which will block the integration test cleanup
58
- cacheControl: [s3deploy.CacheControl.setPublic(), s3deploy.CacheControl.maxAge(cdk.Duration.minutes(1))],
59
- contentType: 'text/html',
60
- metadata: { A: 'aaa', B: 'bbb', C: 'ccc' },
36
+ retainOnDelete: false,
61
37
  });
62
38
 
63
- new s3deploy.BucketDeployment(this, 'DeployMeWithoutDeletingFilesOnDestination', {
39
+ // Test that files not in source are preserved when prune is disabled
40
+ new s3deploy.BucketDeployment(this, 'DeployWithPruneDisabled', {
64
41
  sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
65
42
  destinationBucket,
66
43
  prune: false,
67
44
  retainOnDelete: false,
68
45
  });
69
46
 
70
- new s3deploy.BucketDeployment(this, 'DeployMeWithExcludedFilesOnDestination', {
47
+ // Test exclude filters to skip certain files from deployment
48
+ new s3deploy.BucketDeployment(this, 'DeployWithExclude', {
71
49
  sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
72
50
  destinationBucket,
73
51
  exclude: ['*.gif'],
74
52
  retainOnDelete: false,
75
53
  });
76
54
 
77
- const bucket4 = new s3.Bucket(this, 'Destination4', {
78
- publicReadAccess: false,
79
- removalPolicy: cdk.RemovalPolicy.DESTROY,
80
- autoDeleteObjects: true, // needed for integration test cleanup
55
+ const bucketWithoutExtract = new s3.Bucket(this, 'BucketWithoutExtract', {
56
+ ...commonBucketProps,
81
57
  });
82
58
 
83
- new s3deploy.BucketDeployment(this, 'DeployMeWithoutExtractingFilesOnDestination', {
59
+ // Test that zip files are uploaded as-is when extract is disabled
60
+ new s3deploy.BucketDeployment(this, 'DeployWithoutExtract', {
84
61
  sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
85
- destinationBucket: bucket4,
62
+ destinationBucket: bucketWithoutExtract,
86
63
  extract: false,
87
64
  retainOnDelete: false,
88
65
  });
89
66
 
90
- this.bucket5 = new s3.Bucket(this, 'Destination5', {
91
- publicReadAccess: false,
92
- removalPolicy: cdk.RemovalPolicy.DESTROY,
93
- autoDeleteObjects: true, // needed for integration test cleanup
67
+ this.bucketWithAddSource = new s3.Bucket(this, 'BucketWithAddSource', {
68
+ ...commonBucketProps,
94
69
  });
95
70
 
96
- const deploy5 = new s3deploy.BucketDeployment(this, 'DeployMe5', {
71
+ // Test addSource() method for dynamically adding sources after construction
72
+ // and validate objectKeys output property returns both asset files and added sources
73
+ const deployWithAddSource = new s3deploy.BucketDeployment(this, 'DeployWithAddSource', {
97
74
  sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website-second'))],
98
- destinationBucket: this.bucket5,
99
- retainOnDelete: false, // default is true, which will block the integration test cleanup
75
+ destinationBucket: this.bucketWithAddSource,
76
+ retainOnDelete: false,
100
77
  });
101
- deploy5.addSource(s3deploy.Source.data('some-key', 'helloworld'));
78
+ deployWithAddSource.addSource(s3deploy.Source.data('some-key', 'helloworld'));
102
79
 
80
+ // Output objectKeys to validate they are returned in CloudFormation outputs
103
81
  new cdk.CfnOutput(this, 'customResourceData', {
104
82
  value: cdk.Fn.sub('Object Keys are ${keys}', {
105
- keys: cdk.Fn.join(',', deploy5.objectKeys),
83
+ keys: cdk.Fn.join(',', deployWithAddSource.objectKeys),
106
84
  }),
107
85
  });
108
86
 
109
- const bucket6 = new s3.Bucket(this, 'Destination6', {
110
- publicReadAccess: false,
111
- removalPolicy: cdk.RemovalPolicy.DESTROY,
112
- autoDeleteObjects: true, // needed for integration test cleanup
87
+ const bucketWithoutObjectKeys = new s3.Bucket(this, 'BucketWithoutObjectKeys', {
88
+ ...commonBucketProps,
113
89
  });
114
90
 
115
- new s3deploy.BucketDeployment(this, 'DeployMe6', {
91
+ // Test that objectKeys are not returned when outputObjectKeys is disabled
92
+ new s3deploy.BucketDeployment(this, 'DeployWithoutObjectKeys', {
116
93
  sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website-second'))],
117
- destinationBucket: bucket6,
118
- retainOnDelete: false, // default is true, which will block the integration test cleanup
94
+ destinationBucket: bucketWithoutObjectKeys,
95
+ retainOnDelete: false,
119
96
  outputObjectKeys: false,
120
97
  });
121
98
  }
@@ -128,13 +105,14 @@ const app = new cdk.App({
128
105
  });
129
106
  const testCase = new TestBucketDeployment(app, 'test-bucket-deployments');
130
107
 
131
- // Assert that DeployMeWithoutExtractingFilesOnDestination deploys a zip file to bucket4
132
108
  const integTest = new integ.IntegTest(app, 'integ-test-bucket-deployments', {
133
109
  testCases: [testCase],
134
110
  diffAssets: true,
135
111
  });
112
+
113
+ // Assert that addSource() successfully adds the data source alongside the asset source
136
114
  const listObjectsCall = integTest.assertions.awsApiCall('S3', 'listObjects', {
137
- Bucket: testCase.bucket5.bucketName,
115
+ Bucket: testCase.bucketWithAddSource.bucketName,
138
116
  });
139
117
  listObjectsCall.provider.addToRolePolicy({
140
118
  Effect: 'Allow',
@@ -154,12 +132,12 @@ listObjectsCall.expect(integ.ExpectedResult.objectLike({
154
132
  ),
155
133
  }));
156
134
 
157
- // Assert that there is one object key returned from the custom resource
135
+ // Assert that objectKeys output contains the deployed object keys when outputObjectKeys is enabled (default)
158
136
  const describe = integTest.assertions.awsApiCall('CloudFormation', 'describeStacks', {
159
137
  StackName: 'test-bucket-deployments',
160
138
  });
161
139
 
162
140
  describe.assertAtPath('Stacks.0.Outputs.0.OutputKey', integ.ExpectedResult.stringLikeRegexp('customResourceData'));
163
- describe.assertAtPath('Stacks.0.Outputs.0.OutputValue', integ.ExpectedResult.stringLikeRegexp('Object Keys are ([0-9a-f])+\.zip'));
141
+ describe.assertAtPath('Stacks.0.Outputs.0.OutputValue', integ.ExpectedResult.stringLikeRegexp('Object Keys are ([0-9a-f])+\\.zip(,([0-9a-f])+\\.zip)*'));
164
142
 
165
143
  app.synth();