@@ -86,6 +86,46 @@ export interface IImagePipeline extends cdk.IResource {
8686 */
8787 onCVEDetected ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
8888
89+ /**
90+ * Creates an EventBridge rule for Image Builder image state change events.
91+ *
92+ * @param id Unique identifier for the rule
93+ * @param options Configuration options for the event rule
94+ *
95+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
96+ */
97+ onImageBuildStateChange ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
98+
99+ /**
100+ * Creates an EventBridge rule for Image Builder image build completion events.
101+ *
102+ * @param id Unique identifier for the rule
103+ * @param options Configuration options for the event rule
104+ *
105+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
106+ */
107+ onImageBuildCompleted ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
108+
109+ /**
110+ * Creates an EventBridge rule for Image Builder image build failure events.
111+ *
112+ * @param id Unique identifier for the rule
113+ * @param options Configuration options for the event rule
114+ *
115+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
116+ */
117+ onImageBuildFailed ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
118+
119+ /**
120+ * Creates an EventBridge rule for Image Builder image success events.
121+ *
122+ * @param id Unique identifier for the rule
123+ * @param options Configuration options for the event rule
124+ *
125+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
126+ */
127+ onImageBuildSucceeded ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
128+
89129 /**
90130 * Creates an EventBridge rule for Image Builder image pipeline automatically disabled events.
91131 *
@@ -95,6 +135,16 @@ export interface IImagePipeline extends cdk.IResource {
95135 * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
96136 */
97137 onImagePipelineAutoDisabled ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
138+
139+ /**
140+ * Creates an EventBridge rule for Image Builder wait for action events
141+ *
142+ * @param id Unique identifier for the rule
143+ * @param options Configuration options for the event rule
144+ *
145+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
146+ */
147+ onWaitForAction ( id : string , options ?: events . OnEventOptions ) : events . Rule ;
98148}
99149
100150/**
@@ -371,7 +421,7 @@ abstract class ImagePipelineBase extends cdk.Resource implements IImagePipeline
371421 rule . addTarget ( options . target ) ;
372422 rule . addEventPattern ( {
373423 source : [ 'aws.imagebuilder' ] ,
374- resources : [ this . imagePipelineArn ] ,
424+ ... ( options . eventPattern ?. resources ?. length && { resources : options . eventPattern . resources } ) ,
375425 ...( options . eventPattern ?. detailType ?. length && { detailType : options . eventPattern . detailType } ) ,
376426 ...( options . eventPattern ?. detail !== undefined && { detail : options . eventPattern . detail } ) ,
377427 } ) ;
@@ -387,7 +437,83 @@ abstract class ImagePipelineBase extends cdk.Resource implements IImagePipeline
387437 * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
388438 */
389439 public onCVEDetected ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
390- return this . onEvent ( id , { ...options , eventPattern : { detailType : [ 'EC2 Image Builder CVE Detected' ] } } ) ;
440+ return this . onEvent ( id , {
441+ ...options ,
442+ eventPattern : {
443+ ...options . eventPattern ,
444+ detailType : [ 'EC2 Image Builder CVE Detected' ] ,
445+ resources : [ this . imagePipelineArn ] ,
446+ } ,
447+ } ) ;
448+ }
449+
450+ /**
451+ * Creates an EventBridge rule for Image Builder image state change events.
452+ *
453+ * @param id Unique identifier for the rule
454+ * @param options Configuration options for the event rule
455+ *
456+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
457+ */
458+ public onImageBuildStateChange ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
459+ return this . onEvent ( id , {
460+ ...options ,
461+ eventPattern : { ...options . eventPattern , detailType : [ 'EC2 Image Builder Image State Change' ] } ,
462+ } ) ;
463+ }
464+
465+ /**
466+ * Creates an EventBridge rule for Image Builder image build completion events.
467+ *
468+ * @param id Unique identifier for the rule
469+ * @param options Configuration options for the event rule
470+ *
471+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
472+ */
473+ public onImageBuildCompleted ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
474+ return this . onImageBuildStateChange ( id , {
475+ ...options ,
476+ eventPattern : {
477+ ...options . eventPattern ,
478+ detail : { ...options . eventPattern ?. detail , state : { status : [ 'AVAILABLE' , 'CANCELLED' , 'FAILED' ] } } ,
479+ } ,
480+ } ) ;
481+ }
482+
483+ /**
484+ * Creates an EventBridge rule for Image Builder image build failure events.
485+ *
486+ * @param id Unique identifier for the rule
487+ * @param options Configuration options for the event rule
488+ *
489+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
490+ */
491+ public onImageBuildFailed ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
492+ return this . onImageBuildStateChange ( id , {
493+ ...options ,
494+ eventPattern : {
495+ ...options . eventPattern ,
496+ detail : { ...options . eventPattern ?. detail , state : { status : [ 'FAILED' ] } } ,
497+ } ,
498+ } ) ;
499+ }
500+
501+ /**
502+ * Creates an EventBridge rule for Image Builder image success events.
503+ *
504+ * @param id Unique identifier for the rule
505+ * @param options Configuration options for the event rule
506+ *
507+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
508+ */
509+ public onImageBuildSucceeded ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
510+ return this . onImageBuildStateChange ( id , {
511+ ...options ,
512+ eventPattern : {
513+ ...options . eventPattern ,
514+ detail : { ...options . eventPattern ?. detail , state : { status : [ 'AVAILABLE' ] } } ,
515+ } ,
516+ } ) ;
391517 }
392518
393519 /**
@@ -401,7 +527,25 @@ abstract class ImagePipelineBase extends cdk.Resource implements IImagePipeline
401527 public onImagePipelineAutoDisabled ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
402528 return this . onEvent ( id , {
403529 ...options ,
404- eventPattern : { detailType : [ 'EC2 Image Builder Image Pipeline Automatically Disabled' ] } ,
530+ eventPattern : {
531+ detailType : [ 'EC2 Image Builder Image Pipeline Automatically Disabled' ] ,
532+ resources : [ this . imagePipelineArn ] ,
533+ } ,
534+ } ) ;
535+ }
536+
537+ /**
538+ * Creates an EventBridge rule for Image Builder wait for action events
539+ *
540+ * @param id Unique identifier for the rule
541+ * @param options Configuration options for the event rule
542+ *
543+ * @see https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-eventbridge.html
544+ */
545+ public onWaitForAction ( id : string , options : events . OnEventOptions = { } ) : events . Rule {
546+ return this . onEvent ( id , {
547+ ...options ,
548+ eventPattern : { ...options . eventPattern , detailType : [ 'EC2 Image Builder Workflow Step Waiting' ] } ,
405549 } ) ;
406550 }
407551}
0 commit comments