Skip to content

Commit e323e1e

Browse files
authored
feat: More secure S3 settings (#122)
Force SSL, block all public access and encrypt bucket where we save the layers. Lambda supports all those settings. Fixes #121
1 parent 8fbadbb commit e323e1e

File tree

3 files changed

+900
-14
lines changed

3 files changed

+900
-14
lines changed

src/base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
Stack,
2020
} from 'aws-cdk-lib';
2121
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
22+
import { BucketEncryption } from 'aws-cdk-lib/aws-s3';
2223
import { Construct } from 'constructs';
2324
import { PackageCodebuildFunction } from './package-codebuild-function';
2425
import { PackageNodejsFunction } from './package-nodejs-function';
@@ -141,6 +142,9 @@ export class BaseDependencyPackager extends Construct implements iam.IGrantable,
141142

142143
this.packagesBucket = new s3.Bucket(this, 'Bucket', {
143144
autoDeleteObjects: true,
145+
enforceSSL: true,
146+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
147+
encryption: BucketEncryption.S3_MANAGED,
144148
removalPolicy: RemovalPolicy.DESTROY,
145149
});
146150

test/default.integ.snapshot/Turbo-Layer-Test.assets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@
235235
}
236236
}
237237
},
238-
"3ef59ef101f0ad12362a1e794aa4fbdf90192fc99e828202e7b8ffff7e888ca4": {
238+
"eec3cdcb6f11b28abf2677fd100a9b04905082c33e1e8097ef11ac2dd1111390": {
239239
"source": {
240240
"path": "Turbo-Layer-Test.template.json",
241241
"packaging": "file"
242242
},
243243
"destinations": {
244244
"current_account-current_region": {
245245
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
246-
"objectKey": "3ef59ef101f0ad12362a1e794aa4fbdf90192fc99e828202e7b8ffff7e888ca4.json",
246+
"objectKey": "eec3cdcb6f11b28abf2677fd100a9b04905082c33e1e8097ef11ac2dd1111390.json",
247247
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
248248
}
249249
}

0 commit comments

Comments
 (0)