Skip to content

Commit 180c42d

Browse files
author
Tarun Belani
committed
Remove image pipeline execution settings
1 parent 95558ed commit 180c42d

21 files changed

Lines changed: 18 additions & 1258 deletions

packages/@aws-cdk/aws-imagebuilder-alpha/README.md

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -267,43 +267,6 @@ Pipelines can be started programmatically to trigger image builds on-demand, in
267267
is useful for integrating pipelines with CI/CD workflows, triggering builds based on custom conditions, or creating
268268
images in response to events.
269269

270-
##### Basic Pipeline Start
271-
272-
Start a pipeline execution without additional configuration:
273-
274-
```ts
275-
const builtImage = examplePipeline.start({});
276-
```
277-
278-
##### Tagged Pipeline Builds
279-
280-
Apply custom tags to images created from pipeline executions:
281-
282-
```ts
283-
const taggedImage = examplePipeline.start({
284-
tags: {
285-
BuildNumber: '456',
286-
Environment: 'Production'
287-
}
288-
});
289-
```
290-
291-
##### Triggering on Pipeline Updates
292-
293-
Configure the pipeline to automatically trigger a new build whenever the pipeline itself is updated:
294-
295-
```ts
296-
const triggeredImage = examplePipeline.start({
297-
onUpdate: true,
298-
tags: {
299-
AutoBuild: 'true'
300-
}
301-
});
302-
```
303-
304-
The `start()` method returns an `Image` construct representing the pipeline execution, which can be referenced for
305-
additional operations or outputs.
306-
307270
#### Importing Image Pipelines
308271

309272
Reference existing pipelines created outside CDK:
@@ -1573,7 +1536,9 @@ const distributeContainerWorkflow = imagebuilder.AwsManagedWorkflow.distributeCo
15731536

15741537
### Lifecycle Policy
15751538

1576-
Lifecycle policies help you manage the retention and cleanup of Image Builder resources automatically. These policies define rules for deprecating or deleting old image versions, managing AMI snapshots, and controlling resource costs by removing unused images based on age, count, or other criteria.
1539+
Lifecycle policies help you manage the retention and cleanup of Image Builder resources automatically. These policies
1540+
define rules for deprecating or deleting old image versions, managing AMI snapshots, and controlling resource costs by
1541+
removing unused images based on age, count, or other criteria.
15771542

15781543
#### Lifecycle Policy Basic Usage
15791544

packages/@aws-cdk/aws-imagebuilder-alpha/awslint.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"exclude": [
33
"props-no-arn-refs:@aws-cdk/aws-imagebuilder-alpha.InfrastructureConfigurationProps.ec2InstanceHostResourceGroupArn",
44
"props-physical-name:@aws-cdk/aws-imagebuilder-alpha.ImageProps",
5-
"construct-ctor-props-optional:@aws-cdk/aws-imagebuilder-alpha.Image",
6-
"ref-via-interface:@aws-cdk/aws-imagebuilder-alpha.ImagePipelineExecutionSettings.imagePipeline",
75
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.ContainerType",
86
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowAction",
97
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.WorkflowOnFailure",

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as logs from 'aws-cdk-lib/aws-logs';
77
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
88
import { Construct } from 'constructs';
99
import { IDistributionConfiguration } from './distribution-configuration';
10-
import { Image } from './image';
1110
import { IInfrastructureConfiguration, InfrastructureConfiguration } from './infrastructure-configuration';
1211
import {
1312
buildImageScanningConfiguration,
@@ -313,25 +312,6 @@ export interface ImagePipelineSchedule {
313312
readonly startCondition?: ScheduleStartCondition;
314313
}
315314

316-
/**
317-
* Properties for creating by starting the associated image pipeline.
318-
*/
319-
export interface StartImagePipelineProps {
320-
/**
321-
* Indicates whether to trigger a new image build when an update is made to the image pipeline
322-
*
323-
* @default false
324-
*/
325-
readonly onUpdate?: boolean;
326-
327-
/**
328-
* The tags to apply to the image created from the pipeline
329-
*
330-
* @default None
331-
*/
332-
readonly tags?: { [key: string]: string };
333-
}
334-
335315
/**
336316
* The start condition for the pipeline, indicating the condition under which a pipeline should be triggered.
337317
*/
@@ -729,18 +709,6 @@ export class ImagePipeline extends ImagePipelineBase {
729709
this.imagePipelineDeploymentId = imagePipeline.attrDeploymentId;
730710
}
731711

732-
/**
733-
* Starts an image build from this image pipeline.
734-
*
735-
* @param props Properties for creating by starting the associated image pipeline
736-
*/
737-
public start(props: StartImagePipelineProps): Image {
738-
return new Image(this, 'Image', {
739-
imagePipelineExecutionSettings: { imagePipeline: this, onUpdate: props.onUpdate },
740-
tags: props.tags,
741-
});
742-
}
743-
744712
/**
745713
* Grants the default permissions for building an image to the provided execution role.
746714
*

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

Lines changed: 11 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
77
import { Construct } from 'constructs';
88
import { BaseContainerImage, BaseImage } from './base-image';
99
import { IDistributionConfiguration } from './distribution-configuration';
10-
import { ImagePipeline } from './image-pipeline';
1110
import { IInfrastructureConfiguration, InfrastructureConfiguration } from './infrastructure-configuration';
1211
import { LATEST_VERSION } from './private/constants';
1312
import {
@@ -90,16 +89,7 @@ export interface ImageProps {
9089
* @default - none if the image is created from an image pipeline with `imagePipelineExecutionSettings`. Otherwise,
9190
* a recipe is required.
9291
*/
93-
readonly recipe?: IRecipeBase;
94-
95-
/**
96-
* The image pipeline execution settings of the image, used to create an image by invoking the provided image
97-
* pipeline. You may only specify the `tags` property in conjunction with `imagePipelineExecutionSettings`.
98-
*
99-
* @default - none if the image is created directly using a recipe. Otherwise, the image pipeline execution setting is
100-
* required.
101-
*/
102-
readonly imagePipelineExecutionSettings?: ImagePipelineExecutionSettings;
92+
readonly recipe: IRecipeBase;
10393

10494
/**
10595
* The infrastructure configuration used for building the image.
@@ -205,23 +195,6 @@ export interface ImageProps {
205195
readonly tags?: { [key: string]: string };
206196
}
207197

208-
/**
209-
* The image pipeline execution settings of the image, used to create an image by invoking the provided image pipeline.
210-
*/
211-
export interface ImagePipelineExecutionSettings {
212-
/**
213-
* The image pipeline to start an image build from
214-
*/
215-
readonly imagePipeline: ImagePipeline;
216-
217-
/**
218-
* Indicates whether to trigger a new image build when an update is made to the image pipeline
219-
*
220-
* @default false
221-
*/
222-
readonly onUpdate?: boolean;
223-
}
224-
225198
/**
226199
* Properties for an EC2 Image Builder image
227200
*/
@@ -462,26 +435,21 @@ export class Image extends ImageBase {
462435

463436
Object.defineProperty(this, IMAGE_SYMBOL, { value: true });
464437

465-
this.validateImageProps(props);
466-
467438
this.props = props;
468439

469-
const hasImagePipelineExecutionSettings = props.imagePipelineExecutionSettings !== undefined;
470-
471-
this.infrastructureConfiguration = hasImagePipelineExecutionSettings
472-
? props.imagePipelineExecutionSettings.imagePipeline.infrastructureConfiguration
473-
: (props.infrastructureConfiguration ?? new InfrastructureConfiguration(this, 'InfrastructureConfiguration'));
440+
this.infrastructureConfiguration =
441+
props.infrastructureConfiguration ?? new InfrastructureConfiguration(this, 'InfrastructureConfiguration');
474442

475-
this.executionRole = hasImagePipelineExecutionSettings
476-
? props.imagePipelineExecutionSettings.imagePipeline.executionRole
477-
: getExecutionRole(this, (grantee: iam.IGrantable) => this.grantDefaultExecutionRolePermissions(grantee), {
443+
this.executionRole = getExecutionRole(
444+
this,
445+
(grantee: iam.IGrantable) => this.grantDefaultExecutionRolePermissions(grantee),
446+
{
478447
...props,
479448
imageLogGroup: props.logGroup,
480-
});
449+
},
450+
);
481451

482-
const [image, recipe] = hasImagePipelineExecutionSettings
483-
? this.createImageFromPipelineExecutionSettings(props)
484-
: this.createImageFromRecipe(props);
452+
const [image, recipe] = this.createImageFromRecipe(props);
485453

486454
this.imageName = this.getResourceNameAttribute(image.attrName);
487455
this.imageArn = image.attrArn;
@@ -523,7 +491,7 @@ export class Image extends ImageBase {
523491
* @private
524492
*/
525493
private createImageFromRecipe(props: ImageProps): [CfnImage, IRecipeBase] {
526-
const recipe = props.recipe!;
494+
const recipe = props.recipe;
527495
if (InfrastructureConfiguration.isInfrastructureConfiguration(this.infrastructureConfiguration)) {
528496
this.infrastructureConfiguration._bind({ isContainerBuild: recipe._isContainerRecipe() });
529497
}
@@ -559,27 +527,6 @@ export class Image extends ImageBase {
559527
return [image, recipe];
560528
}
561529

562-
/**
563-
* Creates a CfnImage resource from the image pipeline execution settings provided. This allows creation of images
564-
* by starting an image pipeline.
565-
*
566-
* @param props Props input for the construct
567-
* @private
568-
*/
569-
private createImageFromPipelineExecutionSettings(props: ImageProps): [CfnImage, IRecipeBase] {
570-
const imagePipelineExecutionSettings = props.imagePipelineExecutionSettings!;
571-
572-
const image = new CfnImage(this, 'Resource', {
573-
imagePipelineExecutionSettings: {
574-
deploymentId: imagePipelineExecutionSettings.imagePipeline.imagePipelineDeploymentId,
575-
onUpdate: imagePipelineExecutionSettings.onUpdate,
576-
},
577-
tags: props.tags,
578-
});
579-
580-
return [image, imagePipelineExecutionSettings.imagePipeline._recipe];
581-
}
582-
583530
/**
584531
* Generates the loggingConfiguration property into the `LoggingConfiguration` type in the CloudFormation L1
585532
* definition.
@@ -606,21 +553,4 @@ export class Image extends ImageBase {
606553

607554
return { executionRole: props.deletionExecutionRole.roleArn };
608555
}
609-
610-
/**
611-
* Validates the top-level properties of the image construct. Ensures that the Image gets created from either a recipe
612-
* or an image pipeline.
613-
*
614-
* @param props Props input for the construct
615-
* @private
616-
*/
617-
private validateImageProps(props: ImageProps): void {
618-
if (props.recipe === undefined && props.imagePipelineExecutionSettings === undefined) {
619-
throw new cdk.ValidationError('either recipe or imagePipelineExecutionSettings is required', this);
620-
}
621-
622-
if (props.recipe !== undefined && props.imagePipelineExecutionSettings !== undefined) {
623-
throw new cdk.ValidationError('only one of recipe and imagePipelineExecutionSettings can be provided', this);
624-
}
625-
}
626556
}

packages/@aws-cdk/aws-imagebuilder-alpha/lib/private/image-and-pipeline-props-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export const buildImageScanningConfiguration = <
3737
scope: Construct,
3838
props: PropsT,
3939
): OutputT | undefined => {
40-
if (!props.recipe!._isContainerRecipe() && props.imageScanningEcrRepository !== undefined) {
40+
if (!props.recipe._isContainerRecipe() && props.imageScanningEcrRepository !== undefined) {
4141
throw new cdk.ValidationError('imageScanningEcrRepository is only supported for container recipe builds', scope);
4242
}
4343

44-
if (!props.recipe!._isContainerRecipe() && props.imageScanningEcrTags !== undefined) {
44+
if (!props.recipe._isContainerRecipe() && props.imageScanningEcrTags !== undefined) {
4545
throw new cdk.ValidationError('imageScanningEcrTags is only supported for container recipe builds', scope);
4646
}
4747

packages/@aws-cdk/aws-imagebuilder-alpha/lib/private/policy-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export const defaultExecutionRolePolicy = <PropsT extends ImagePipelineProps | I
277277
];
278278

279279
const hasProps = props !== undefined;
280-
if (!hasProps || (props.recipe!._isImageRecipe() && props.distributionConfiguration !== undefined)) {
280+
if (!hasProps || (props.recipe._isImageRecipe() && props.distributionConfiguration !== undefined)) {
281281
// Distribution-specific permissions if distribution settings are provided. All permissions here are for AMI builds
282282
// specifically.
283283
policies.push(
@@ -365,7 +365,7 @@ export const defaultExecutionRolePolicy = <PropsT extends ImagePipelineProps | I
365365
);
366366

367367
// Add image scanning ECR permissions for container builds
368-
if (!hasProps || props.recipe!._isContainerRecipe()) {
368+
if (!hasProps || props.recipe._isContainerRecipe()) {
369369
policies.push(
370370
new iam.PolicyStatement({
371371
effect: iam.Effect.ALLOW,

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -427,37 +427,6 @@ describe('ImagePipeline', () => {
427427
});
428428
});
429429

430-
test('creates an image when starting a pipeline', () => {
431-
const imagePipeline = new ImagePipeline(stack, 'ImagePipeline', {
432-
recipe: ImageRecipe.fromImageRecipeName(stack, 'ImageRecipe', 'imported-image-recipe'),
433-
});
434-
imagePipeline.start({ onUpdate: true, tags: { key1: 'value1', key2: 'value2' } });
435-
436-
const template = Template.fromStack(stack);
437-
438-
template.resourceCountIs('AWS::IAM::Role', 1);
439-
template.resourceCountIs('AWS::IAM::InstanceProfile', 1);
440-
template.resourceCountIs('AWS::ImageBuilder::InfrastructureConfiguration', 1);
441-
template.resourceCountIs('AWS::ImageBuilder::ImagePipeline', 1);
442-
template.resourceCountIs('AWS::ImageBuilder::Image', 1);
443-
expect(Object.keys(template.toJSON().Resources)).toHaveLength(5);
444-
445-
template.templateMatches({
446-
Resources: {
447-
ImagePipelineImage364D5BF8: Match.objectEquals({
448-
Type: 'AWS::ImageBuilder::Image',
449-
Properties: {
450-
ImagePipelineExecutionSettings: {
451-
DeploymentId: { 'Fn::GetAtt': ['ImagePipeline7DDDE57F', 'DeploymentId'] },
452-
OnUpdate: true,
453-
},
454-
Tags: { key1: 'value1', key2: 'value2' },
455-
},
456-
}),
457-
},
458-
});
459-
});
460-
461430
test('generates an execution role when workflows are provided', () => {
462431
const imagePipeline = new ImagePipeline(stack, 'ImagePipeline', {
463432
recipe: ImageRecipe.fromImageRecipeName(stack, 'ImageRecipe', 'imported-image-recipe'),

0 commit comments

Comments
 (0)