@@ -67,7 +67,7 @@ export interface ComponentProps {
6767 /**
6868 * The operating system platform of the component.
6969 */
70- readonly platform : OSVersion ;
70+ readonly platform : Platform ;
7171
7272 /**
7373 * The name of the component.
@@ -143,7 +143,7 @@ export interface ComponentAttributes {
143143 /**
144144 * The version of the component
145145 *
146- * @default the latest version of the component, x.x.x
146+ * @default - the latest version of the component, x.x.x
147147 */
148148 readonly componentVersion ?: string ;
149149}
@@ -168,7 +168,7 @@ export interface AwsManagedComponentAttributes {
168168 /**
169169 * The version of the AWS-managed component
170170 *
171- * @default the latest version of the component, x.x.x
171+ * @default - the latest version of the component, x.x.x
172172 */
173173 readonly componentVersion ?: string ;
174174
@@ -180,7 +180,7 @@ export interface AwsManagedComponentAttributes {
180180 * @default - none if using `this.fromAwsManagedComponentAttributes()`, otherwise a platform is
181181 * required when using the pre-defined managed component methods
182182 */
183- readonly platform ?: OSVersion ;
183+ readonly platform ?: Platform ;
184184}
185185
186186/**
@@ -200,7 +200,7 @@ export interface AwsMarketplaceComponentAttributes {
200200 /**
201201 * The version of the AWS Marketplace component
202202 *
203- * @default The latest version of the component, x.x.x
203+ * @default - the latest version of the component, x.x.x
204204 */
205205 readonly componentVersion ?: string ;
206206}
@@ -273,7 +273,7 @@ export interface ComponentDocumentStep {
273273 /**
274274 * The condition to apply to the step. If the condition is false, then the step is skipped
275275 *
276- * @default no condition is applied to the step and it gets executed
276+ * @default - no condition is applied to the step and it gets executed
277277 */
278278 readonly if ?: any ;
279279
@@ -282,7 +282,7 @@ export interface ComponentDocumentStep {
282282 *
283283 * @default None
284284 */
285- readonly loop ?: any ;
285+ readonly loop ?: ComponentDocumentLoop ;
286286
287287 /**
288288 * The timeout of the step
@@ -299,6 +299,53 @@ export interface ComponentDocumentStep {
299299 readonly onFailure ?: ComponentOnFailure ;
300300}
301301
302+ /**
303+ * The looping construct of a component defines a repeated sequence of instructions
304+ */
305+ export interface ComponentDocumentLoop {
306+ /**
307+ * The name of the loop, which can be used to reference
308+ *
309+ * @default loop
310+ */
311+ readonly name ?: string ;
312+
313+ /**
314+ * The for loop iterates on a range of integers specified within a boundary outlined by the start and end of the
315+ * variables
316+ *
317+ * @default - none if `forEach` is provided. otherwise, `for` is required.
318+ */
319+ readonly for ?: ComponentDocumentForLoop ;
320+
321+ /**
322+ * The forEach loop iterates on an explicit list of values, which can be strings and chained expressions
323+ *
324+ * @default - none if `for` is provided. otherwise, `forEach` is required.
325+ */
326+ readonly forEach ?: string [ ] ;
327+ }
328+
329+ /**
330+ * The for loop iterates on a range of integers specified within a boundary outlined by the start and end of the
331+ * variables. The iterating values are in the set [start, end] and includes boundary values.
332+ */
333+ export interface ComponentDocumentForLoop {
334+ /**
335+ * Starting value of iteration. Does not accept chaining expressions.
336+ */
337+ readonly start : number ;
338+ /**
339+ * Ending value of iteration. Does not accept chaining expressions.
340+ */
341+ readonly end : number ;
342+ /**
343+ * Difference by which an iterating value is updated through addition. It must be a negative or positive non-zero
344+ * value. Does not accept chaining expressions.
345+ */
346+ readonly updateBy : number ;
347+ }
348+
302349/**
303350 * The action for a step within the component document
304351 */
@@ -571,9 +618,11 @@ export abstract class ComponentData {
571618 steps : phase . steps . map ( ( step ) => ( {
572619 name : step . name ,
573620 action : step . action ,
574- inputs : step . inputs ,
575621 ...( step . onFailure !== undefined && { onFailure : step . onFailure } ) ,
576622 ...( step . timeout !== undefined && { timeoutSeconds : step . timeout . toSeconds ( ) } ) ,
623+ ...( step . if !== undefined && { if : step . if } ) ,
624+ ...( step . loop !== undefined && { loop : step . loop } ) ,
625+ inputs : step . inputs ,
577626 } ) ) ,
578627 } ) ) ,
579628 } ) ;
@@ -700,7 +749,7 @@ export abstract class AwsManagedComponent {
700749 allowedPlatforms : [ Platform . LINUX , Platform . WINDOWS ] ,
701750 } ) ;
702751
703- if ( attrs . platform ?. platform === Platform . WINDOWS ) {
752+ if ( attrs . platform === Platform . WINDOWS ) {
704753 return this . fromAwsManagedComponentAttributes ( scope , id , {
705754 componentName : 'aws-cli-version-2-windows' ,
706755 componentVersion : attrs . componentVersion ,
@@ -728,7 +777,7 @@ export abstract class AwsManagedComponent {
728777 allowedPlatforms : [ Platform . LINUX , Platform . WINDOWS ] ,
729778 } ) ;
730779
731- if ( attrs . platform ?. platform === Platform . WINDOWS ) {
780+ if ( attrs . platform === Platform . WINDOWS ) {
732781 return this . fromAwsManagedComponentAttributes ( scope , id , {
733782 componentName : 'hello-world-windows' ,
734783 componentVersion : attrs . componentVersion ,
@@ -756,7 +805,7 @@ export abstract class AwsManagedComponent {
756805 allowedPlatforms : [ Platform . LINUX , Platform . WINDOWS ] ,
757806 } ) ;
758807
759- if ( attrs . platform ?. platform === Platform . WINDOWS ) {
808+ if ( attrs . platform === Platform . WINDOWS ) {
760809 return this . fromAwsManagedComponentAttributes ( scope , id , {
761810 componentName : 'python-3-windows' ,
762811 componentVersion : attrs . componentVersion ,
@@ -784,7 +833,7 @@ export abstract class AwsManagedComponent {
784833 allowedPlatforms : [ Platform . LINUX , Platform . WINDOWS ] ,
785834 } ) ;
786835
787- if ( attrs . platform ?. platform === Platform . WINDOWS ) {
836+ if ( attrs . platform === Platform . WINDOWS ) {
788837 return this . fromAwsManagedComponentAttributes ( scope , id , {
789838 componentName : 'reboot-windows' ,
790839 componentVersion : attrs . componentVersion ,
@@ -814,7 +863,7 @@ export abstract class AwsManagedComponent {
814863 allowedPlatforms : [ Platform . LINUX , Platform . WINDOWS ] ,
815864 } ) ;
816865
817- if ( attrs . platform ?. platform === Platform . WINDOWS ) {
866+ if ( attrs . platform === Platform . WINDOWS ) {
818867 return this . fromAwsManagedComponentAttributes ( scope , id , {
819868 componentName : 'stig-build-windows' ,
820869 componentVersion : attrs . componentVersion ,
@@ -842,7 +891,7 @@ export abstract class AwsManagedComponent {
842891 allowedPlatforms : [ Platform . LINUX , Platform . WINDOWS ] ,
843892 } ) ;
844893
845- if ( attrs . platform ?. platform === Platform . WINDOWS ) {
894+ if ( attrs . platform === Platform . WINDOWS ) {
846895 return this . fromAwsManagedComponentAttributes ( scope , id , {
847896 componentName : 'update-windows' ,
848897 componentVersion : attrs . componentVersion ,
@@ -923,7 +972,7 @@ export abstract class AwsManagedComponent {
923972 throw new cdk . ValidationError ( `platform cannot be a token for ${ component } ` , scope ) ;
924973 }
925974
926- if ( ! allowedPlatforms . includes ( attrs . platform . platform ) ) {
975+ if ( ! allowedPlatforms . includes ( attrs . platform ) ) {
927976 throw new cdk . ValidationError ( `${ attrs . platform } is not a supported platform for ${ component } ` , scope ) ;
928977 }
929978 }
@@ -1061,6 +1110,11 @@ export class Component extends ComponentBase {
10611110 ) . resourceName ! ;
10621111
10631112 const [ componentNameFromArn , componentVersionFromArn ] = ( ( ) => {
1113+ if ( cdk . Token . isUnresolved ( componentNameVersion ) ) {
1114+ const componentNameVersionSplit = cdk . Fn . split ( '/' , componentNameVersion ) ;
1115+ return [ cdk . Fn . select ( 0 , componentNameVersionSplit ) , cdk . Fn . select ( 1 , componentNameVersionSplit ) ] ;
1116+ }
1117+
10641118 const componentNameVersionSplit = componentNameVersion . split ( '/' ) ;
10651119 return [ componentNameVersionSplit [ 0 ] , componentNameVersionSplit [ 1 ] ] ;
10661120 } ) ( ) ;
@@ -1130,7 +1184,7 @@ export class Component extends ComponentBase {
11301184 this . validateComponentName ( ) ;
11311185
11321186 props . supportedOsVersions ?. forEach ( ( osVersion ) => {
1133- if ( osVersion . platform !== props . platform . platform ) {
1187+ if ( osVersion . platform !== props . platform ) {
11341188 throw new cdk . ValidationError (
11351189 `os version ${ osVersion . osVersion } is not compatible with platform ${ props . platform } ` ,
11361190 this ,
@@ -1146,7 +1200,7 @@ export class Component extends ComponentBase {
11461200 version : componentVersion ,
11471201 changeDescription : props . changeDescription ,
11481202 description : props . description ,
1149- platform : props . platform . platform ,
1203+ platform : props . platform ,
11501204 kmsKeyId : props . kmsKey ?. keyArn ,
11511205 tags : props . tags ,
11521206 ...( props . data . isS3Reference ? { uri : props . data . value } : { data : props . data . value } ) ,
0 commit comments