@@ -25,6 +25,7 @@ const props: ImagePipelineProps = {
2525 amiIdSsmPath : '/ec2-image-builder/al2-x86' ,
2626 amiIdSsmAccountId : '11223344556' ,
2727 amiIdSsmRegion : 'us-east-1' ,
28+ name : 'TestImagePipeline' ,
2829} ;
2930
3031const propsWithNetworking : ImagePipelineProps = {
@@ -69,6 +70,21 @@ const propsWithVolumeConfig: ImagePipelineProps = {
6970 distributionRegions : [ 'us-east-1' ] ,
7071} ;
7172
73+ const propsWithSchedule : ImagePipelineProps = {
74+ ...props ,
75+ schedule : {
76+ scheduleExpression : 'cron(0 0 * * ? *)' ,
77+ pipelineExecutionStartCondition : 'EXPRESSION_MATCH_ONLY' ,
78+ } ,
79+ } ;
80+
81+ const propsWithDefaultSchedule : ImagePipelineProps = {
82+ ...props ,
83+ schedule : {
84+ scheduleExpression : 'cron(0 12 * * ? *)' ,
85+ } ,
86+ } ;
87+
7288beforeAll ( ( ) => {
7389 process . env . CDK_DEFAULT_ACCOUNT = '123456789012' ;
7490 process . env . CDK_DEFAULT_REGION = 'us-east-1' ;
@@ -83,6 +99,12 @@ beforeAll(() => {
8399 template = Template . fromStack ( testStack ) ;
84100} ) ;
85101
102+ test ( 'Image Pipeline is created with custom name' , ( ) => {
103+ template . hasResourceProperties ( 'AWS::ImageBuilder::ImagePipeline' , {
104+ Name : 'TestImagePipeline' ,
105+ } ) ;
106+ } ) ;
107+
86108test ( 'Infrastructure Configuration SNS topic is created' , ( ) => {
87109 template . resourceCountIs ( 'AWS::SNS::Topic' , 1 ) ;
88110} ) ;
@@ -238,6 +260,43 @@ test('Image Pipeline has Inspector vulnerability scans configured', () => {
238260 } ) ;
239261} ) ;
240262
263+ test ( 'Image Pipeline supports schedule configuration' , ( ) => {
264+ const app1 = new cdk . App ( ) ;
265+ const testStack1 = new cdk . Stack ( app1 , 'testStackWithSchedule' , {
266+ env : {
267+ account : process . env . CDK_DEFAULT_ACCOUNT ,
268+ region : process . env . CDK_DEFAULT_REGION ,
269+ } ,
270+ } ) ;
271+
272+ new ImagePipeline ( testStack1 , 'ImagePipelineWithSchedule' , propsWithSchedule ) ;
273+ const templateWithSchedule = Template . fromStack ( testStack1 ) ;
274+
275+ templateWithSchedule . hasResourceProperties ( 'AWS::ImageBuilder::ImagePipeline' , {
276+ Schedule : {
277+ ScheduleExpression : 'cron(0 0 * * ? *)' ,
278+ PipelineExecutionStartCondition : 'EXPRESSION_MATCH_ONLY' ,
279+ } ,
280+ } ) ;
281+
282+ // Test with default execution condition
283+ const app2 = new cdk . App ( ) ;
284+ const testStack2 = new cdk . Stack ( app2 , 'testStackWithDefaultSchedule' , {
285+ env : {
286+ account : process . env . CDK_DEFAULT_ACCOUNT ,
287+ region : process . env . CDK_DEFAULT_REGION ,
288+ } ,
289+ } ) ;
290+
291+ new ImagePipeline ( testStack2 , 'ImagePipelineWithDefaultSchedule' , propsWithDefaultSchedule ) ;
292+ const templateWithDefaultSchedule = Template . fromStack ( testStack2 ) ;
293+
294+ templateWithDefaultSchedule . hasResourceProperties ( 'AWS::ImageBuilder::ImagePipeline' , {
295+ Schedule : {
296+ ScheduleExpression : 'cron(0 12 * * ? *)' ,
297+ } ,
298+ } ) ;
299+ } ) ;
241300
242301test ( 'ImagePipeline exposes components as properties' , ( ) => {
243302 const app = new cdk . App ( ) ;
0 commit comments