Skip to content

Commit fb26499

Browse files
authored
Merge pull request #107 from henrykie/multi-volume-image
feat(construct)!: support for multiple EBS volume configurations in a single pipeline.
2 parents 8c6921c + 0a17178 commit fb26499

File tree

4 files changed

+93
-42
lines changed

4 files changed

+93
-42
lines changed

API.md

Lines changed: 48 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,20 @@ new ImagePipeline(this, "MyImagePipeline", {
6464
infraConfigName: 'MyInfrastructureConfiguration',
6565
imageRecipe: 'MyImageRecipe',
6666
pipelineName: 'MyImagePipeline',
67-
parentImage: 'ami-0e1d30f2c40c4c701'
67+
parentImage: 'ami-0e1d30f2c40c4c701',
68+
ebsVolumeConfigurations: [
69+
{
70+
deviceName: '/dev/xvda',
71+
ebs: {
72+
encrypted: true,
73+
iops: 200,
74+
kmsKeyId: 'alias/app1/key',
75+
volumeSize: 20,
76+
volumeType: 'gp3',
77+
throughput: 1000,
78+
},
79+
},
80+
],
6881
})
6982
// ...
7083
```
@@ -223,6 +236,7 @@ image_pipeline = ImagePipeline(
223236
# ...
224237
```
225238
239+
226240
### Component Documents
227241
228242
---

src/index.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ export interface ComponentProps {
2525
*/
2626
readonly version: string;
2727
}
28+
export interface VolumeProps {
29+
/**
30+
* Name of the volume
31+
*/
32+
readonly deviceName: string;
33+
/**
34+
* EBS Block Store Parameters
35+
*/
36+
readonly ebs: imagebuilder.CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty;
37+
}
2838

2939
export interface ImagePipelineProps {
3040
/**
@@ -78,8 +88,8 @@ export interface ImagePipelineProps {
7888
*/
7989
readonly platform?: string;
8090
/**
81-
* Email used to receive Image Builder Pipeline Notifications via SNS
82-
*/
91+
* Email used to receive Image Builder Pipeline Notifications via SNS
92+
*/
8393
readonly email?: string;
8494
/**
8595
* List of security group IDs for the Infrastructure Configuration
@@ -90,13 +100,9 @@ export interface ImagePipelineProps {
90100
*/
91101
readonly subnetId?: string;
92102
/**
93-
* Configuration for the AMI's EBS volume
94-
*/
95-
readonly ebsVolumeConfiguration?: imagebuilder.CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty;
96-
/**
97-
* Name of the AMI's EBS volume
103+
* Configuration for the AMI's EBS volumes
98104
*/
99-
readonly ebsVolumeName?: string;
105+
readonly ebsVolumeConfigurations?: VolumeProps[];
100106
/**
101107
* Set to true if you want to enable continuous vulnerability scans through AWS Inpector
102108
*/
@@ -217,13 +223,10 @@ export class ImagePipeline extends Construct {
217223
},
218224
};
219225
};
220-
if (props.ebsVolumeConfiguration && props.ebsVolumeName) {
226+
if (props.ebsVolumeConfigurations) {
221227
imageRecipeProps = {
222228
...imageRecipeProps,
223-
blockDeviceMappings: [{
224-
deviceName: props.ebsVolumeName,
225-
ebs: props.ebsVolumeConfiguration,
226-
}],
229+
blockDeviceMappings: props.ebsVolumeConfigurations,
227230
};
228231
}
229232
imageRecipe = new imagebuilder.CfnImageRecipe(this, 'ImageRecipe', imageRecipeProps);
@@ -274,7 +277,7 @@ export class ImagePipeline extends Construct {
274277
LaunchPermissionConfiguration: {
275278
UserIds: props.distributionAccountIDs,
276279
},
277-
KmsKeyId: props.ebsVolumeConfiguration?.kmsKeyId ?? 'aws/ebs', //use default AWS-managed key if one isn't given
280+
KmsKeyId: props.ebsVolumeConfigurations ? props.ebsVolumeConfigurations[0].ebs.kmsKeyId : 'aws/ebs', //use default AWS-managed key if one isn't given
278281
},
279282
};
280283
distributionsList.push(distributionConfig);

test/imagepipeline.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,19 @@ const propsWithVolumeConfig: ImagePipelineProps = {
6666
kmsKeyAlias: 'alias/app1/key',
6767
securityGroups: ['sg-12345678'],
6868
subnetId: 'subnet-12345678',
69-
ebsVolumeName: '/dev/xvda',
70-
ebsVolumeConfiguration: {
71-
encrypted: true,
72-
iops: 200,
73-
kmsKeyId: 'alias/app1/key',
74-
volumeSize: 20,
75-
volumeType: 'gp3',
76-
throughput: 1000,
77-
},
69+
ebsVolumeConfigurations: [
70+
{
71+
deviceName: '/dev/xvda',
72+
ebs: {
73+
encrypted: true,
74+
iops: 200,
75+
kmsKeyId: 'alias/app1/key',
76+
volumeSize: 20,
77+
volumeType: 'gp3',
78+
throughput: 1000,
79+
},
80+
},
81+
],
7882
enableCrossAccountDistribution: true,
7983
distributionAccountIDs: ['111222333444'],
8084
distributionRegions: ['us-east-1'],

0 commit comments

Comments
 (0)