@@ -282,22 +282,6 @@ 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-
301285 if ( this . props . autoTerminationPolicyIdleTimeout !== undefined && ! cdk . Token . isUnresolved ( this . props . autoTerminationPolicyIdleTimeout ) ) {
302286 const idletimeOutSeconds = this . props . autoTerminationPolicyIdleTimeout . toSeconds ( ) ;
303287
@@ -306,30 +290,7 @@ export class EmrCreateCluster extends sfn.TaskStateBase {
306290 }
307291 }
308292
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- }
293+ this . validatePropsRelatedToReleaseLabel ( ) ;
333294 }
334295
335296 /**
@@ -549,6 +510,49 @@ export class EmrCreateCluster extends sfn.TaskStateBase {
549510 return value === '' || isNaN ( Number ( value ) ) ;
550511 }
551512 }
513+
514+ private validatePropsRelatedToReleaseLabel ( ) {
515+ if ( this . props . releaseLabel !== undefined && ! cdk . Token . isUnresolved ( this . props . releaseLabel ) ) {
516+ this . validateReleaseLabel ( this . props . releaseLabel ) ;
517+ }
518+
519+ if ( this . props . stepConcurrencyLevel !== undefined && ! cdk . Token . isUnresolved ( this . props . stepConcurrencyLevel ) ) {
520+ if ( this . props . stepConcurrencyLevel < 1 || this . props . stepConcurrencyLevel > 256 ) {
521+ throw new ValidationError ( `Step concurrency level must be in range [1, 256], but got ${ this . props . stepConcurrencyLevel } .` , this ) ;
522+ }
523+ if ( this . props . releaseLabel && this . props . stepConcurrencyLevel !== 1 ) {
524+ const [ major , minor ] = this . props . releaseLabel . slice ( 4 ) . split ( '.' ) ;
525+ if ( Number ( major ) < 5 || ( Number ( major ) === 5 && Number ( minor ) < 28 ) ) {
526+ throw new ValidationError ( `Step concurrency is only supported in EMR release version 5.28.0 and above but got ${ this . props . releaseLabel } .` , this ) ;
527+ }
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