@@ -282,54 +282,7 @@ export class EmrCreateCluster extends sfn.TaskStateBase {
282282
283283 this . taskPolicies = this . createPolicyStatements ( this . _serviceRole , this . _clusterRole , this . _autoScalingRole ) ;
284284
285- if ( this . props . releaseLabel !== undefined && ! cdk . Token . isUnresolved ( this . props . releaseLabel ) ) {
286- this . validateReleaseLabel ( this . props . releaseLabel ) ;
287- }
288-
289- if ( this . props . stepConcurrencyLevel !== undefined && ! cdk . Token . isUnresolved ( this . props . stepConcurrencyLevel ) ) {
290- if ( this . props . stepConcurrencyLevel < 1 || this . props . stepConcurrencyLevel > 256 ) {
291- throw new ValidationError ( `Step concurrency level must be in range [1, 256], but got ${ this . props . stepConcurrencyLevel } .` , this ) ;
292- }
293- if ( this . props . releaseLabel && this . props . stepConcurrencyLevel !== 1 ) {
294- const [ major , minor ] = this . props . releaseLabel . slice ( 4 ) . split ( '.' ) ;
295- if ( Number ( major ) < 5 || ( Number ( major ) === 5 && Number ( minor ) < 28 ) ) {
296- throw new ValidationError ( `Step concurrency is only supported in EMR release version 5.28.0 and above but got ${ this . props . releaseLabel } .` , this ) ;
297- }
298- }
299- }
300-
301- if ( this . props . autoTerminationPolicyIdleTimeout !== undefined && ! cdk . Token . isUnresolved ( this . props . autoTerminationPolicyIdleTimeout ) ) {
302- const idletimeOutSeconds = this . props . autoTerminationPolicyIdleTimeout . toSeconds ( ) ;
303-
304- if ( idletimeOutSeconds < 60 || idletimeOutSeconds > 604800 ) {
305- throw new ValidationError ( `\`autoTerminationPolicyIdleTimeout\` must be between 60 and 604800 seconds, got ${ idletimeOutSeconds } seconds.` , this ) ;
306- }
307- }
308-
309- // EMR EBS limitations https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-custom-ami-root-volume-size.html#emr-root-volume-overview
310- if ( this . props . ebsRootVolumeSize !== undefined &&
311- ( this . props . ebsRootVolumeSize . toGibibytes ( ) < 15 || this . props . ebsRootVolumeSize . toGibibytes ( ) > 100 ) ) {
312- throw new ValidationError (
313- `ebsRootVolumeSize must be between 15 and 100 GiB, but got ${ this . props . ebsRootVolumeSize . toGibibytes ( ) } GiB.` , this ) ;
314- }
315-
316- if ( this . props . releaseLabel &&
317- ( this . props . ebsRootVolumeThroughput !== undefined || this . props . ebsRootVolumeIops !== undefined ) ) {
318- const minVersion = '6.15.0' ;
319- if ( semver . lt ( this . props . releaseLabel . slice ( 4 ) , minVersion ) ) {
320- throw new ValidationError ( `ebsRootVolumeThroughput and ebsRootVolumeIops are only supported in EMR release version ${ minVersion } and above but got ${ this . props . releaseLabel } .` , this ) ;
321- }
322- }
323-
324- if ( this . props . ebsRootVolumeThroughput !== undefined && ( this . props . ebsRootVolumeThroughput < 125 || this . props . ebsRootVolumeThroughput > 1000 ) ) {
325- throw new ValidationError (
326- `ebsRootVolumeThroughput must be between 125 and 1000 MiB/s, but got ${ this . props . ebsRootVolumeThroughput } MiB/s.` , this ) ;
327- }
328-
329- if ( this . props . ebsRootVolumeIops !== undefined && ( this . props . ebsRootVolumeIops < 3000 || this . props . ebsRootVolumeIops > 16000 ) ) {
330- throw new ValidationError (
331- `ebsRootVolumeIops must be between 3000 and 16000, but got ${ this . props . ebsRootVolumeIops } .` , this ) ;
332- }
285+ this . validateProps ( ) ;
333286 }
334287
335288 /**
@@ -549,6 +502,57 @@ export class EmrCreateCluster extends sfn.TaskStateBase {
549502 return value === '' || isNaN ( Number ( value ) ) ;
550503 }
551504 }
505+
506+ private validateProps ( ) {
507+ if ( this . props . releaseLabel !== undefined && ! cdk . Token . isUnresolved ( this . props . releaseLabel ) ) {
508+ this . validateReleaseLabel ( this . props . releaseLabel ) ;
509+ }
510+
511+ if ( this . props . stepConcurrencyLevel !== undefined && ! cdk . Token . isUnresolved ( this . props . stepConcurrencyLevel ) ) {
512+ if ( this . props . stepConcurrencyLevel < 1 || this . props . stepConcurrencyLevel > 256 ) {
513+ throw new ValidationError ( `Step concurrency level must be in range [1, 256], but got ${ this . props . stepConcurrencyLevel } .` , this ) ;
514+ }
515+ if ( this . props . releaseLabel && this . props . stepConcurrencyLevel !== 1 ) {
516+ const [ major , minor ] = this . props . releaseLabel . slice ( 4 ) . split ( '.' ) ;
517+ if ( Number ( major ) < 5 || ( Number ( major ) === 5 && Number ( minor ) < 28 ) ) {
518+ throw new ValidationError ( `Step concurrency is only supported in EMR release version 5.28.0 and above but got ${ this . props . releaseLabel } .` , this ) ;
519+ }
520+ }
521+ }
522+
523+ if ( this . props . autoTerminationPolicyIdleTimeout !== undefined && ! cdk . Token . isUnresolved ( this . props . autoTerminationPolicyIdleTimeout ) ) {
524+ const idletimeOutSeconds = this . props . autoTerminationPolicyIdleTimeout . toSeconds ( ) ;
525+
526+ if ( idletimeOutSeconds < 60 || idletimeOutSeconds > 604800 ) {
527+ throw new ValidationError ( `\`autoTerminationPolicyIdleTimeout\` must be between 60 and 604800 seconds, got ${ idletimeOutSeconds } seconds.` , this ) ;
528+ }
529+ }
530+
531+ // EMR EBS limitations https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-custom-ami-root-volume-size.html#emr-root-volume-overview
532+ if ( this . props . ebsRootVolumeSize !== undefined &&
533+ ( this . props . ebsRootVolumeSize . toGibibytes ( ) < 15 || this . props . ebsRootVolumeSize . toGibibytes ( ) > 100 ) ) {
534+ throw new ValidationError (
535+ `ebsRootVolumeSize must be between 15 and 100 GiB, but got ${ this . props . ebsRootVolumeSize . toGibibytes ( ) } GiB.` , this ) ;
536+ }
537+
538+ if ( this . props . releaseLabel &&
539+ ( this . props . ebsRootVolumeThroughput !== undefined || this . props . ebsRootVolumeIops !== undefined ) ) {
540+ const minVersion = '6.15.0' ;
541+ if ( semver . lt ( this . props . releaseLabel . slice ( 4 ) , minVersion ) ) {
542+ throw new ValidationError ( `ebsRootVolumeThroughput and ebsRootVolumeIops are only supported in EMR release version ${ minVersion } and above but got ${ this . props . releaseLabel } .` , this ) ;
543+ }
544+ }
545+
546+ if ( this . props . ebsRootVolumeThroughput !== undefined && ( this . props . ebsRootVolumeThroughput < 125 || this . props . ebsRootVolumeThroughput > 1000 ) ) {
547+ throw new ValidationError (
548+ `ebsRootVolumeThroughput must be between 125 and 1000 MiB/s, but got ${ this . props . ebsRootVolumeThroughput } MiB/s.` , this ) ;
549+ }
550+
551+ if ( this . props . ebsRootVolumeIops !== undefined && ( this . props . ebsRootVolumeIops < 3000 || this . props . ebsRootVolumeIops > 16000 ) ) {
552+ throw new ValidationError (
553+ `ebsRootVolumeIops must be between 3000 and 16000, but got ${ this . props . ebsRootVolumeIops } .` , this ) ;
554+ }
555+ }
552556}
553557
554558export namespace EmrCreateCluster {
0 commit comments