Skip to content

Commit e558a8e

Browse files
committed
add parameters to embedded-linux-pipeline: accessLoggingBucket, artifactBucket, outputBucket
1 parent 3f9d517 commit e558a8e

File tree

8 files changed

+94
-47
lines changed

8 files changed

+94
-47
lines changed

lib/build-image-pipeline.ts

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export interface BuildImagePipelineProps extends cdk.StackProps {
2929
readonly dataBucket: s3.IBucket;
3030
/** The ECR Repository to push to. */
3131
readonly repository: IRepository;
32+
/** Access logging bucket to use */
33+
accessLoggingBucket?: s3.Bucket;
34+
/** Artifact bucket to use */
35+
artifactBucket?: s3.Bucket;
3236
}
3337

3438
/**
@@ -98,24 +102,37 @@ export class BuildImagePipelineStack extends cdk.Stack {
98102
input: sourceOutput,
99103
});
100104

101-
const accessLoggingBucket = new s3.Bucket(this, 'ArtifactAccessLogging', {
102-
versioned: true,
103-
enforceSSL: true,
104-
});
105-
const encryptionKey = new kms.Key(this, 'PipelineArtifactKey', {
106-
removalPolicy: RemovalPolicy.DESTROY,
107-
enableKeyRotation: true,
108-
});
109-
const artifactBucket = new s3.Bucket(this, 'PipelineArtifacts', {
110-
versioned: true,
111-
enforceSSL: true,
112-
serverAccessLogsBucket: accessLoggingBucket,
113-
encryptionKey,
114-
encryption: s3.BucketEncryption.KMS,
115-
blockPublicAccess: new s3.BlockPublicAccess(
116-
s3.BlockPublicAccess.BLOCK_ALL
117-
),
118-
});
105+
let accessLoggingBucket: s3.IBucket;
106+
107+
if (props.accessLoggingBucket){
108+
accessLoggingBucket = props.accessLoggingBucket;
109+
} else {
110+
accessLoggingBucket = new s3.Bucket(this, 'ArtifactAccessLogging', {
111+
versioned: true,
112+
enforceSSL: true,
113+
});
114+
}
115+
116+
let artifactBucket: s3.IBucket;
117+
118+
if (props.artifactBucket){
119+
artifactBucket = props.artifactBucket;
120+
} else {
121+
const encryptionKey = new kms.Key(this, 'PipelineArtifactKey', {
122+
removalPolicy: RemovalPolicy.DESTROY,
123+
enableKeyRotation: true,
124+
});
125+
artifactBucket = new s3.Bucket(this, 'PipelineArtifacts', {
126+
versioned: true,
127+
enforceSSL: true,
128+
serverAccessLogsBucket: accessLoggingBucket,
129+
encryptionKey,
130+
encryption: s3.BucketEncryption.KMS,
131+
blockPublicAccess: new s3.BlockPublicAccess(
132+
s3.BlockPublicAccess.BLOCK_ALL
133+
),
134+
});
135+
}
119136

120137
const pipeline = new codepipeline.Pipeline(this, 'BuildImagePipeline', {
121138
artifactBucket,

lib/embedded-linux-pipeline.ts

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

source-repo/kas/build.buildspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ phases:
3939

4040
artifacts:
4141
discard-paths: true
42+
base-directory: kas/
4243
files:
4344
- $TMP_DIR/build/tmp/deploy/images/qemux86-64/aws-biga-image-qemux86-64*
4445
- $TMP_DIR/build/tmp/log/cve/cve-summary*

source-repo/meta-aws-demo/build.buildspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ phases:
4646

4747
artifacts:
4848
discard-paths: true
49+
base-directory: meta-aws-demo/
4950
files:
5051
- $TMP_DIR/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64*
5152
- $TMP_DIR/tmp/log/cve/cve-summary*

source-repo/nxp-imx/build.buildspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ phases:
5252

5353
artifacts:
5454
discard-paths: true
55+
base-directory: nxp-imx/
5556
files:
5657
# $TMP_DIR is not supported by imx bsp / distro
5758
- build/tmp/deploy/images/imx93evk/*

source-repo/poky-ami/build.buildspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ phases:
6565
- find /downloads -atime +30 -type d -empty -delete
6666
artifacts:
6767
discard-paths: true
68+
base-directory: poky-ami/
6869
files:
6970
- $TMP_DIR/tmp/deploy/images/aws-ec2-arm64/core-image-minimal*
7071
- $TMP_DIR/tmp/log/cve/cve-summary*

source-repo/poky/build.buildspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ phases:
4646

4747
artifacts:
4848
discard-paths: true
49+
base-directory: poky/
4950
files:
5051
- $TMP_DIR/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64*
5152
- $TMP_DIR/tmp/log/cve/cve-summary*

source-repo/renesas/build.buildspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ phases:
4141

4242
artifacts:
4343
discard-paths: true
44+
base-directory: renesas/
4445
files:
4546
- h3ulcb/build/tmp/deploy/images/h3ulcb/*

0 commit comments

Comments
 (0)