Skip to content

Commit 13ffadb

Browse files
author
Tarun Belani
committed
Addressed review comments
1 parent 588d4bc commit 13ffadb

12 files changed

+67
-21
lines changed

packages/@aws-cdk/aws-imagebuilder-alpha/lib/image-recipe.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export class ImageRecipe extends ImageRecipeBase {
321321

322322
this.validateImageRecipeName();
323323

324-
this.addBlockDevices(...(props.blockDevices ?? []));
324+
this.addBlockDevice(...(props.blockDevices ?? []));
325325

326326
const components: CfnImageRecipe.ComponentConfigurationProperty[] | undefined = props.components?.map(
327327
(component) => ({
@@ -362,10 +362,17 @@ export class ImageRecipe extends ImageRecipeBase {
362362
*
363363
* @param blockDevices The list of block devices to attach
364364
*/
365-
public addBlockDevices(...blockDevices: ec2.BlockDevice[]): void {
365+
public addBlockDevice(...blockDevices: ec2.BlockDevice[]): void {
366366
this.blockDevices.push(...blockDevices);
367367
}
368368

369+
/**
370+
* Renders the input block devices, into the `BlockDeviceMapping[]` structure that CfnImageRecipe expects to receive.
371+
* This is rendered at synthesis time, as users can add additional block devices with `addBlockDevice`, after the
372+
* construct has been instantiated.
373+
*
374+
* @private
375+
*/
369376
private renderBlockDevices(): CfnImageRecipe.InstanceBlockDeviceMappingProperty[] | undefined {
370377
const blockDevices = this.blockDevices.map((blockDevice): CfnImageRecipe.InstanceBlockDeviceMappingProperty => {
371378
const ebsDevice = blockDevice.volume.ebsDevice;
@@ -380,18 +387,24 @@ export class ImageRecipe extends ImageRecipeBase {
380387
...(ebsDevice?.volumeType !== undefined && { volumeType: ebsDevice.volumeType }),
381388
};
382389

383-
const mappingEnabled = blockDevice.mappingEnabled ?? true;
384390
return {
385391
deviceName: blockDevice.deviceName,
386392
virtualName: blockDevice.volume.virtualName,
387-
...(!mappingEnabled && { noDevice: '' }),
393+
...(blockDevice.mappingEnabled === false && { noDevice: '' }),
388394
...(Object.keys(ebs).length && { ebs }),
389395
};
390396
});
391397

392398
return blockDevices.length ? blockDevices : undefined;
393399
}
394400

401+
/**
402+
* Generates the additional instance configuration property into the `AdditionalInstanceConfiguration` type in the
403+
* CloudFormation L1 definition.
404+
*
405+
* @param props The props passed as input to the construct
406+
* @private
407+
*/
395408
private buildAdditionalInstanceConfiguration(
396409
props: ImageRecipeProps,
397410
): CfnImageRecipe.AdditionalInstanceConfigurationProperty | undefined {

packages/@aws-cdk/aws-imagebuilder-alpha/test/image-recipe.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('Image Recipe', () => {
181181
},
182182
});
183183

184-
imageRecipe.addBlockDevices(
184+
imageRecipe.addBlockDevice(
185185
{
186186
deviceName: '/dev/sda2',
187187
volume: ec2.BlockDeviceVolume.ebs(75, {

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.all-parameters.image-recipe.js.snapshot/aws-cdk-imagebuilder-image-recipe-all-parameters.assets.json

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

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.all-parameters.image-recipe.js.snapshot/aws-cdk-imagebuilder-image-recipe-all-parameters.template.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@
116116
}
117117
}
118118
},
119+
"Outputs": {
120+
"ImageRecipeVersion": {
121+
"Value": {
122+
"Fn::GetAtt": [
123+
"ImageRecipe8C789631",
124+
"Version"
125+
]
126+
}
127+
}
128+
},
119129
"Parameters": {
120130
"BootstrapVersion": {
121131
"Type": "AWS::SSM::Parameter::Value<String>",

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.all-parameters.image-recipe.js.snapshot/manifest.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.all-parameters.image-recipe.js.snapshot/tree.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.all-parameters.image-recipe.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const imageRecipe = new imagebuilder.ImageRecipe(stack, 'ImageRecipe', {
8484
},
8585
});
8686

87-
imageRecipe.addBlockDevices({
87+
imageRecipe.addBlockDevice({
8888
deviceName: '/dev/sda2',
8989
volume: ec2.BlockDeviceVolume.ebs(75, {
9090
encrypted: true,
@@ -96,6 +96,8 @@ imageRecipe.addBlockDevices({
9696
}),
9797
});
9898

99+
new cdk.CfnOutput(stack, 'ImageRecipeVersion', { value: imageRecipe.imageRecipeVersion });
100+
99101
new integ.IntegTest(app, 'ImageRecipeTest', {
100102
testCases: [stack],
101103
});

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.default-parameters.image-recipe.js.snapshot/aws-cdk-imagebuilder-image-recipe-default-parameters.assets.json

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

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.default-parameters.image-recipe.js.snapshot/aws-cdk-imagebuilder-image-recipe-default-parameters.template.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
}
1010
}
1111
},
12+
"Outputs": {
13+
"ImageRecipeVersion": {
14+
"Value": {
15+
"Fn::GetAtt": [
16+
"ImageRecipe8C789631",
17+
"Version"
18+
]
19+
}
20+
}
21+
},
1222
"Parameters": {
1323
"BootstrapVersion": {
1424
"Type": "AWS::SSM::Parameter::Value<String>",

packages/@aws-cdk/aws-imagebuilder-alpha/test/integ.default-parameters.image-recipe.js.snapshot/manifest.json

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

0 commit comments

Comments
 (0)