@@ -32,9 +32,20 @@ export class FromCloudFormation {
32
32
// nothing to for any but return it
33
33
public static getAny ( value : any ) { return value ; }
34
34
35
- // nothing to do - if 'value' is not a boolean or a Token,
36
- // a validator should report that at runtime
37
- public static getBoolean ( value : any ) : boolean | IResolvable { return value ; }
35
+ public static getBoolean ( value : any ) : boolean | IResolvable {
36
+ if ( typeof value === 'string' ) {
37
+ // CloudFormation allows passing strings as boolean
38
+ switch ( value ) {
39
+ case 'true' : return true ;
40
+ case 'false' : return false ;
41
+ default : throw new Error ( `Expected 'true' or 'false' for boolean value, got: '${ value } '` ) ;
42
+ }
43
+ }
44
+
45
+ // in all other cases, just return the value,
46
+ // and let a validator handle if it's not a boolean
47
+ return value ;
48
+ }
38
49
39
50
public static getDate ( value : any ) : Date | IResolvable {
40
51
// if the date is a deploy-time value, just return it
@@ -80,9 +91,8 @@ export class FromCloudFormation {
80
91
}
81
92
82
93
// return a number, if the input can be parsed as one
83
- let parsedValue ;
84
94
if ( typeof value === 'string' ) {
85
- parsedValue = parseFloat ( value ) ;
95
+ const parsedValue = parseFloat ( value ) ;
86
96
if ( ! isNaN ( parsedValue ) ) {
87
97
return parsedValue ;
88
98
}
@@ -338,8 +348,8 @@ export class CfnParser {
338
348
autoScalingRollingUpdate : parseAutoScalingRollingUpdate ( policy . AutoScalingRollingUpdate ) ,
339
349
autoScalingScheduledAction : parseAutoScalingScheduledAction ( policy . AutoScalingScheduledAction ) ,
340
350
codeDeployLambdaAliasUpdate : parseCodeDeployLambdaAliasUpdate ( policy . CodeDeployLambdaAliasUpdate ) ,
341
- enableVersionUpgrade : policy . EnableVersionUpgrade ,
342
- useOnlineResharding : policy . UseOnlineResharding ,
351
+ enableVersionUpgrade : FromCloudFormation . getBoolean ( policy . EnableVersionUpgrade ) ,
352
+ useOnlineResharding : FromCloudFormation . getBoolean ( policy . UseOnlineResharding ) ,
343
353
} ) ;
344
354
345
355
function parseAutoScalingReplacingUpdate ( p : any ) : CfnAutoScalingReplacingUpdate | undefined {
@@ -359,7 +369,7 @@ export class CfnParser {
359
369
minSuccessfulInstancesPercent : FromCloudFormation . getNumber ( p . MinSuccessfulInstancesPercent ) ,
360
370
pauseTime : FromCloudFormation . getString ( p . PauseTime ) ,
361
371
suspendProcesses : FromCloudFormation . getStringArray ( p . SuspendProcesses ) ,
362
- waitOnResourceSignals : p . WaitOnResourceSignals ,
372
+ waitOnResourceSignals : FromCloudFormation . getBoolean ( p . WaitOnResourceSignals ) ,
363
373
} ) ;
364
374
}
365
375
0 commit comments