|
| 1 | +diff --git a/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts b/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts |
| 2 | +index 5d782dfb6b..f4d8ec7d2f 100644 |
| 3 | +--- a/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts |
| 4 | ++++ b/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts |
| 5 | +@@ -258,6 +258,13 @@ export interface BucketDeploymentProps { |
| 6 | + */ |
| 7 | + readonly vpcSubnets?: ec2.SubnetSelection; |
| 8 | + |
| 9 | ++ /** |
| 10 | ++ * Security group to use with the vpc and subnet. |
| 11 | ++ * |
| 12 | ++ * @default - the Vpc default strategy if not specified |
| 13 | ++ */ |
| 14 | ++ readonly securityGroups?: ec2.SecurityGroup[]; |
| 15 | ++ |
| 16 | + /** |
| 17 | + * If set to true, uploads will precompute the value of `x-amz-content-sha256` |
| 18 | + * and include it in the signed S3 request headers. |
| 19 | +@@ -345,6 +352,7 @@ export class BucketDeployment extends Construct { |
| 20 | + ephemeralStorageSize: props.ephemeralStorageSize, |
| 21 | + vpc: props.vpc, |
| 22 | + vpcSubnets: props.vpcSubnets, |
| 23 | ++ securityGroups: props.securityGroups, |
| 24 | + filesystem: accessPoint ? lambda.FileSystem.fromEfsAccessPoint( |
| 25 | + accessPoint, |
| 26 | + mountPath, |
| 27 | +diff --git a/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts b/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts |
| 28 | +index 34801b97bb..fa0457eca0 100644 |
| 29 | +--- a/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts |
| 30 | ++++ b/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts |
| 31 | +@@ -1090,7 +1090,7 @@ test('deployment allows vpc to be implicitly supplied to lambda', () => { |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | +-test('deployment allows vpc and subnets to be implicitly supplied to lambda', () => { |
| 36 | ++test('deployment allows vpc, subnets and security groups to be explicitly supplied to lambda', () => { |
| 37 | + |
| 38 | + // GIVEN |
| 39 | + const stack = new cdk.Stack(); |
| 40 | +@@ -1101,6 +1101,14 @@ test('deployment allows vpc and subnets to be implicitly supplied to lambda', () |
| 41 | + availabilityZone: vpc.availabilityZones[0], |
| 42 | + cidrBlock: vpc.vpcCidrBlock, |
| 43 | + }); |
| 44 | ++ const sg: ec2.SecurityGroup[] = [ |
| 45 | ++ new ec2.SecurityGroup(stack, 'sg1', { |
| 46 | ++ vpc, |
| 47 | ++ allowAllOutbound: false, |
| 48 | ++ description: 'custom security group', |
| 49 | ++ securityGroupName: 'controlled egress', |
| 50 | ++ }), |
| 51 | ++ ]; |
| 52 | + |
| 53 | + // WHEN |
| 54 | + new s3deploy.BucketDeployment(stack, 'DeployWithVpc2', { |
| 55 | +@@ -1110,6 +1118,7 @@ test('deployment allows vpc and subnets to be implicitly supplied to lambda', () |
| 56 | + vpcSubnets: { |
| 57 | + availabilityZones: [vpc.availabilityZones[0]], |
| 58 | + }, |
| 59 | ++ securityGroups: sg, |
| 60 | + }); |
| 61 | + |
| 62 | + // THEN |
| 63 | +@@ -1118,7 +1127,7 @@ test('deployment allows vpc and subnets to be implicitly supplied to lambda', () |
| 64 | + SecurityGroupIds: [ |
| 65 | + { |
| 66 | + 'Fn::GetAtt': [ |
| 67 | +- 'CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756Cc8a39596cb8641929fcf6a288bc9db5ab7b0f656adSecurityGroup11274779', |
| 68 | ++ 'sg15CEFF4E3', |
| 69 | + 'GroupId', |
| 70 | + ], |
| 71 | + }, |
0 commit comments