Skip to content

Commit

Permalink
feat: More secure S3 settings (#122)
Browse files Browse the repository at this point in the history
Force SSL, block all public access and encrypt bucket where we save the layers. Lambda supports all those settings.

Fixes #121
  • Loading branch information
kichik authored Jan 24, 2024
1 parent 8fbadbb commit e323e1e
Show file tree
Hide file tree
Showing 3 changed files with 900 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Stack,
} from 'aws-cdk-lib';
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
import { BucketEncryption } from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
import { PackageCodebuildFunction } from './package-codebuild-function';
import { PackageNodejsFunction } from './package-nodejs-function';
Expand Down Expand Up @@ -141,6 +142,9 @@ export class BaseDependencyPackager extends Construct implements iam.IGrantable,

this.packagesBucket = new s3.Bucket(this, 'Bucket', {
autoDeleteObjects: true,
enforceSSL: true,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
encryption: BucketEncryption.S3_MANAGED,
removalPolicy: RemovalPolicy.DESTROY,
});

Expand Down
4 changes: 2 additions & 2 deletions test/default.integ.snapshot/Turbo-Layer-Test.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@
}
}
},
"3ef59ef101f0ad12362a1e794aa4fbdf90192fc99e828202e7b8ffff7e888ca4": {
"eec3cdcb6f11b28abf2677fd100a9b04905082c33e1e8097ef11ac2dd1111390": {
"source": {
"path": "Turbo-Layer-Test.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "3ef59ef101f0ad12362a1e794aa4fbdf90192fc99e828202e7b8ffff7e888ca4.json",
"objectKey": "eec3cdcb6f11b28abf2677fd100a9b04905082c33e1e8097ef11ac2dd1111390.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Loading

0 comments on commit e323e1e

Please sign in to comment.