@@ -11,6 +11,7 @@ import { IInfrastructureConfiguration, InfrastructureConfiguration } from './inf
1111import {
1212 buildImageScanningConfiguration ,
1313 buildImageTestsConfiguration ,
14+ buildWorkflows ,
1415} from './private/image-and-pipeline-props-helper' ;
1516import { defaultExecutionRolePolicy , getExecutionRole } from './private/policy-helper' ;
1617import { IRecipeBase } from './recipe-base' ;
@@ -19,7 +20,7 @@ import { WorkflowConfiguration } from './workflow';
1920const IMAGE_PIPELINE_SYMBOL = Symbol . for ( '@aws-cdk/aws-imagebuilder-alpha.ImagePipeline' ) ;
2021
2122/**
22- * An EC2 Image Builder Image Pipline .
23+ * An EC2 Image Builder Image Pipeline .
2324 */
2425export interface IImagePipeline extends cdk . IResource {
2526 /**
@@ -85,46 +86,6 @@ export interface IImagePipeline extends cdk.IResource {
8586 */
8687 onCVEDetected ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
8788
88- /**
89- * Creates an EventBridge rule for Image Builder image state change events.
90- *
91- * @param id Unique identifier for the rule
92- * @param options Configuration options for the event rule
93- *
94- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
95- */
96- onImageBuildStateChange ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
97-
98- /**
99- * Creates an EventBridge rule for Image Builder image completion events.
100- *
101- * @param id Unique identifier for the rule
102- * @param options Configuration options for the event rule
103- *
104- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
105- */
106- onImageBuildCompleted ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
107-
108- /**
109- * Creates an EventBridge rule for Image Builder image failure events.
110- *
111- * @param id Unique identifier for the rule
112- * @param options Configuration options for the event rule
113- *
114- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
115- */
116- onImageBuildFailed ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
117-
118- /**
119- * Creates an EventBridge rule for Image Builder image success events.
120- *
121- * @param id Unique identifier for the rule
122- * @param options Configuration options for the event rule
123- *
124- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
125- */
126- onImageBuildSuccess ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
127-
12889 /**
12990 * Creates an EventBridge rule for Image Builder image pipeline automatically disabled events.
13091 *
@@ -134,16 +95,6 @@ export interface IImagePipeline extends cdk.IResource {
13495 * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
13596 */
13697 onImagePipelineAutoDisabled ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
137-
138- /**
139- * Creates an EventBridge rule for Image Builder wait for action events
140- *
141- * @param id Unique identifier for the rule
142- * @param options Configuration options for the event rule
143- *
144- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
145- */
146- onWaitForAction ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
14798}
14899
149100/**
@@ -232,7 +183,7 @@ export interface ImagePipelineProps {
232183
233184 /**
234185 * The log group to use for images created from the image pipeline. By default, a log group will be created with the
235- * format `/aws/imagebuilder/<image-name>`, with a 90-day retention policy .
186+ * format `/aws/imagebuilder/<image-name>`.
236187 *
237188 * @default - a log group will be created
238189 */
@@ -295,9 +246,11 @@ export interface ImagePipelineSchedule {
295246 readonly expression : events . Schedule ;
296247
297248 /**
298- * The number of consecutive failures allowed before the pipeline is automatically disabled.
249+ * The number of consecutive failures allowed before the pipeline is automatically disabled. This value must be
250+ * between 1 and 10.
299251 *
300- * @default - the pipeline will not be disabled automatically on consecutive failures
252+ * @default - no auto-disable policy is configured and the pipeline is not automatically disabled on consecutive
253+ * failures
301254 */
302255 readonly autoDisableFailureCount ?: number ;
303256
@@ -307,13 +260,6 @@ export interface ImagePipelineSchedule {
307260 * @default ScheduleStartCondition.EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE
308261 */
309262 readonly startCondition ?: ScheduleStartCondition ;
310-
311- /**
312- * The timezone in which the schedule expression is evaluated.
313- *
314- * @default UTC
315- */
316- readonly timezone ?: cdk . TimeZone ;
317263}
318264
319265/**
@@ -405,7 +351,15 @@ abstract class ImagePipelineBase extends cdk.Resource implements IImagePipeline
405351 * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
406352 */
407353 public onEvent ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
408- return this . buildEvent ( id , options ) ;
354+ const rule = new events . Rule ( this , id , options ) ;
355+ rule . addTarget ( options . target ) ;
356+ rule . addEventPattern ( {
357+ source : [ 'aws.imagebuilder' ] ,
358+ resources : [ this . imagePipelineArn ] ,
359+ ...( options . eventPattern ?. detailType ?. length && { detailType : options . eventPattern . detailType } ) ,
360+ ...( options . eventPattern ?. detail !== undefined && { detail : options . eventPattern . detail } ) ,
361+ } ) ;
362+ return rule ;
409363 }
410364
411365 /**
@@ -417,57 +371,7 @@ abstract class ImagePipelineBase extends cdk.Resource implements IImagePipeline
417371 * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
418372 */
419373 public onCVEDetected ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
420- return this . buildEvent ( id , options , 'EC2 Image Builder CVE Detected' ) ;
421- }
422-
423- /**
424- * Creates an EventBridge rule for Image Builder image state change events.
425- *
426- * @param id Unique identifier for the rule
427- * @param options Configuration options for the event rule
428- *
429- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
430- */
431- public onImageBuildStateChange ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
432- return this . buildEvent ( id , options , 'EC2 Image Builder Image State Change' ) ;
433- }
434-
435- /**
436- * Creates an EventBridge rule for Image Builder image completion events.
437- *
438- * @param id Unique identifier for the rule
439- * @param options Configuration options for the event rule
440- *
441- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
442- */
443- public onImageBuildCompleted ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
444- return this . buildEvent ( id , options , 'EC2 Image Builder Image State Change' , {
445- state : { status : [ 'AVAILABLE' , 'CANCELLED' , 'FAILED' ] } ,
446- } ) ;
447- }
448-
449- /**
450- * Creates an EventBridge rule for Image Builder image failure events.
451- *
452- * @param id Unique identifier for the rule
453- * @param options Configuration options for the event rule
454- *
455- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
456- */
457- public onImageBuildFailed ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
458- return this . buildEvent ( id , options , 'EC2 Image Builder Image State Change' , { state : { status : [ 'FAILED' ] } } ) ;
459- }
460-
461- /**
462- * Creates an EventBridge rule for Image Builder image success events.
463- *
464- * @param id Unique identifier for the rule
465- * @param options Configuration options for the event rule
466- *
467- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
468- */
469- public onImageBuildSuccess ( id : string , options ?: events . OnEventOptions ) : events . Rule {
470- return this . buildEvent ( id , options , 'EC2 Image Builder Image State Change' , { state : { status : [ 'AVAILABLE' ] } } ) ;
374+ return this . onEvent ( id , { ...options , eventPattern : { detailType : [ 'EC2 Image Builder CVE Detected' ] } } ) ;
471375 }
472376
473377 /**
@@ -479,36 +383,10 @@ abstract class ImagePipelineBase extends cdk.Resource implements IImagePipeline
479383 * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
480384 */
481385 public onImagePipelineAutoDisabled ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
482- return this . buildEvent ( id , options , 'EC2 Image Builder Image Pipeline Automatically Disabled' ) ;
483- }
484-
485- /**
486- * Creates an EventBridge rule for Image Builder wait for action events
487- *
488- * @param id Unique identifier for the rule
489- * @param options Configuration options for the event rule
490- *
491- * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
492- */
493- public onWaitForAction ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
494- return this . buildEvent ( id , options , 'EC2 Image Builder Workflow Step Waiting' ) ;
495- }
496-
497- protected buildEvent (
498- id : string ,
499- options : events . OnEventOptions = { } ,
500- detailType ?: string ,
501- detail ?: { [ key : string ] : any } ,
502- ) : events . Rule {
503- const rule = new events . Rule ( this , id , options ) ;
504- rule . addTarget ( options . target ) ;
505- rule . addEventPattern ( {
506- source : [ 'aws.imagebuilder' ] ,
507- resources : [ this . imagePipelineArn ] ,
508- ...( detailType && { detailType : [ detailType ] } ) ,
509- ...( detail !== undefined && { detail } ) ,
386+ return this . onEvent ( id , {
387+ ...options ,
388+ eventPattern : { detailType : [ 'EC2 Image Builder Image Pipeline Automatically Disabled' ] } ,
510389 } ) ;
511- return rule ;
512390 }
513391}
514392
@@ -618,14 +496,16 @@ export class ImagePipeline extends ImagePipelineBase {
618496 description : props . description ,
619497 ...( props . recipe . _isImageRecipe ( ) && { imageRecipeArn : props . recipe . imageRecipeArn } ) ,
620498 ...( props . recipe . _isContainerRecipe ( ) && { containerRecipeArn : props . recipe . containerRecipeArn } ) ,
499+ ...( props . enabled !== undefined && { status : props . enabled ? 'ENABLED' : 'DISABLED' } ) ,
621500 infrastructureConfigurationArn : this . infrastructureConfiguration . infrastructureConfigurationArn ,
622501 distributionConfigurationArn : props . distributionConfiguration ?. distributionConfigurationArn ,
502+ enhancedImageMetadataEnabled : props . enhancedImageMetadataEnabled ,
503+ executionRole : this . executionRole ?. roleArn ,
623504 schedule : this . buildSchedule ( props ) ,
624505 loggingConfiguration : this . buildLoggingConfiguration ( props ) ,
625- enhancedImageMetadataEnabled : props . enhancedImageMetadataEnabled ,
626506 imageTestsConfiguration : buildImageTestsConfiguration ( props ) ,
627507 imageScanningConfiguration : buildImageScanningConfiguration ( scope , props ) ,
628- executionRole : this . executionRole ?. roleArn ,
508+ workflows : buildWorkflows ( props ) ,
629509 tags : props . tags ,
630510 } ) ;
631511
@@ -673,7 +553,6 @@ export class ImagePipeline extends ImagePipelineBase {
673553
674554 return {
675555 scheduleExpression : schedule . expression . expressionString ,
676- ...( schedule . timezone && { timezone : schedule . timezone . timezoneName } ) ,
677556 ...( schedule . autoDisableFailureCount !== undefined && {
678557 autoDisablePolicy : {
679558 failureCount : schedule . autoDisableFailureCount ,
@@ -685,6 +564,12 @@ export class ImagePipeline extends ImagePipelineBase {
685564 } ;
686565 }
687566
567+ /**
568+ * Generates the loggingConfiguration property into the `LoggingConfiguration` type in the CloudFormation L1
569+ * definition.
570+ *
571+ * @param props Props input for the construct
572+ */
688573 private buildLoggingConfiguration = (
689574 props : ImagePipelineProps ,
690575 ) : CfnImagePipeline . PipelineLoggingConfigurationProperty | undefined => {
0 commit comments