Skip to content

Commit 792a260

Browse files
nmussyrix0rrr
authored andcommitted
feat(codebuild): make artifact encryption configurable (#3230)
1 parent b0963bd commit 792a260

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

packages/@aws-cdk/aws-codebuild/lib/artifacts.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ export interface S3ArtifactsProps extends ArtifactsProps {
113113
* @default true - files will be archived
114114
*/
115115
readonly packageZip?: boolean;
116+
117+
/**
118+
* If this is false, build output will not be encrypted.
119+
* This is useful if the artifact to publish a static website or sharing content with others
120+
*
121+
* @default true - output will be encrypted
122+
*/
123+
readonly encryption?: boolean;
116124
}
117125

118126
/**
@@ -136,6 +144,7 @@ class S3Artifacts extends Artifacts {
136144
namespaceType: this.props.includeBuildId === false ? 'NONE' : 'BUILD_ID',
137145
name: this.props.name,
138146
packaging: this.props.packageZip === false ? 'NONE' : 'ZIP',
147+
encryptionDisabled: this.props.encryption === false ? true : undefined,
139148
}
140149
};
141150
}

packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,36 @@ export = {
933933

934934
test.done();
935935
},
936+
937+
'disabledEncryption is set'(test: Test) {
938+
const stack = new cdk.Stack();
939+
const bucket = new s3.Bucket(stack, 'MyBucket');
940+
const project = new codebuild.Project(stack, 'MyProject', {
941+
source: codebuild.Source.s3({
942+
bucket,
943+
path: 'some/path',
944+
}),
945+
});
946+
947+
project.addSecondaryArtifact(codebuild.Artifacts.s3({
948+
bucket,
949+
path: 'another/path',
950+
name: 'name',
951+
identifier: 'artifact1',
952+
encryption: false,
953+
}));
954+
955+
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
956+
"SecondaryArtifacts": [
957+
{
958+
"ArtifactIdentifier": "artifact1",
959+
"EncryptionDisabled": true,
960+
},
961+
],
962+
}));
963+
964+
test.done();
965+
},
936966
},
937967

938968
'artifacts': {

0 commit comments

Comments
 (0)