@@ -50,7 +50,13 @@ export interface EmbeddedLinuxPipelineProps extends cdk.StackProps {
5050 readonly layerRepoName ?: string ;
5151 /** Additional policy statements to add to the build project. */
5252 readonly buildPolicyAdditions ?: iam . PolicyStatement [ ] ;
53- }
53+ /** Access logging bucket to use */
54+ readonly accessLoggingBucket ?: s3 . Bucket ;
55+ /** Artifact bucket to use */
56+ readonly artifactBucket ?: s3 . Bucket ;
57+ /** Output bucket to use */
58+ readonly outputBucket ?: s3 . Bucket | VMImportBucket ;
59+ }
5460
5561/**
5662 * The stack for creating a build pipeline.
@@ -80,11 +86,16 @@ export class EmbeddedLinuxPipelineStack extends cdk.Stack {
8086 let outputBucket : s3 . IBucket | VMImportBucket ;
8187 let environmentVariables = { } ;
8288 let scriptAsset ! : Asset ;
89+ let accessLoggingBucket : s3 . IBucket ;
8390
84- const accessLoggingBucket = new s3 . Bucket ( this , 'ArtifactAccessLogging' , {
85- versioned : true ,
86- enforceSSL : true ,
87- } ) ;
91+ if ( props . accessLoggingBucket ) {
92+ accessLoggingBucket = props . accessLoggingBucket ;
93+ } else {
94+ accessLoggingBucket = new s3 . Bucket ( this , 'ArtifactAccessLogging' , {
95+ versioned : true ,
96+ enforceSSL : true ,
97+ } ) ;
98+ }
8899
89100 if ( props . projectKind && props . projectKind == ProjectKind . PokyAmi ) {
90101 scriptAsset = new Asset ( this , 'CreateAMIScript' , {
@@ -99,14 +110,17 @@ export class EmbeddedLinuxPipelineStack extends cdk.Stack {
99110 enableKeyRotation : true ,
100111 }
101112 ) ;
102-
103- outputBucket = new VMImportBucket ( this , 'PipelineOutput' , {
104- versioned : true ,
105- enforceSSL : true ,
106- encryptionKey : outputBucketEncryptionKey ,
107- encryptionKeyArn : outputBucketEncryptionKey . keyArn ,
108- serverAccessLogsBucket : accessLoggingBucket ,
109- } ) ;
113+ if ( props . outputBucket ) {
114+ outputBucket = props . outputBucket ;
115+ } else {
116+ outputBucket = new VMImportBucket ( this , 'PipelineOutput' , {
117+ versioned : true ,
118+ enforceSSL : true ,
119+ encryptionKey : outputBucketEncryptionKey ,
120+ encryptionKeyArn : outputBucketEncryptionKey . keyArn ,
121+ serverAccessLogsBucket : accessLoggingBucket ,
122+ } ) ;
123+ }
110124 environmentVariables = {
111125 IMPORT_BUCKET : {
112126 type : BuildEnvironmentVariableType . PLAINTEXT ,
@@ -122,28 +136,38 @@ export class EmbeddedLinuxPipelineStack extends cdk.Stack {
122136 } ,
123137 } ;
124138 } else {
125- outputBucket = new s3 . Bucket ( this , 'PipelineOutput' , {
139+ if ( props . outputBucket ) {
140+ outputBucket = props . outputBucket ;
141+ } else {
142+ outputBucket = new s3 . Bucket ( this , 'PipelineOutput' , {
143+ versioned : true ,
144+ enforceSSL : true ,
145+ serverAccessLogsBucket : accessLoggingBucket ,
146+ } ) ;
147+ }
148+ }
149+
150+ let artifactBucket : s3 . IBucket ;
151+
152+ if ( props . artifactBucket ) {
153+ artifactBucket = props . artifactBucket ;
154+ } else {
155+ const encryptionKey = new kms . Key ( this , 'PipelineArtifactKey' , {
156+ removalPolicy : RemovalPolicy . DESTROY ,
157+ enableKeyRotation : true ,
158+ } ) ;
159+ artifactBucket = new s3 . Bucket ( this , 'PipelineArtifacts' , {
126160 versioned : true ,
127161 enforceSSL : true ,
128162 serverAccessLogsBucket : accessLoggingBucket ,
163+ encryptionKey,
164+ encryption : s3 . BucketEncryption . KMS ,
165+ blockPublicAccess : new s3 . BlockPublicAccess (
166+ s3 . BlockPublicAccess . BLOCK_ALL
167+ ) ,
129168 } ) ;
130169 }
131170
132- const encryptionKey = new kms . Key ( this , 'PipelineArtifactKey' , {
133- removalPolicy : RemovalPolicy . DESTROY ,
134- enableKeyRotation : true ,
135- } ) ;
136- const artifactBucket = new s3 . Bucket ( this , 'PipelineArtifacts' , {
137- versioned : true ,
138- enforceSSL : true ,
139- serverAccessLogsBucket : accessLoggingBucket ,
140- encryptionKey,
141- encryption : s3 . BucketEncryption . KMS ,
142- blockPublicAccess : new s3 . BlockPublicAccess (
143- s3 . BlockPublicAccess . BLOCK_ALL
144- ) ,
145- } ) ;
146-
147171 /** Create our CodePipeline Actions. */
148172 const sourceRepo = new SourceRepo ( this , 'SourceRepo' , {
149173 ...props ,
0 commit comments