Skip to content

Commit

Permalink
chore(stepfunctions-tasks): revert AutoTerminationPolicy (#17481)
Browse files Browse the repository at this point in the history
This reverts commit: #16976.

`AutoTerminationPolicy` was never supported by stepfunctions,
even though it is supported by EMR. This was not discovered 
until it was used since the documentation does not mention this
limitation of stepfunctions.

Since it never worked, we are okay with the breaking change here.

Closes #17452.
  • Loading branch information
kaizencc authored Nov 12, 2021
1 parent 6f2a5d6 commit 876eb84
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 101 deletions.
6 changes: 5 additions & 1 deletion allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ strengthened:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps

# Remove IO2 from autoscaling EbsDeviceVolumeType. This value is not supported
# at the moment and was not supported in the past.
removed:@aws-cdk/aws-autoscaling.EbsDeviceVolumeType.IO2
removed:@aws-cdk/aws-autoscaling.EbsDeviceVolumeType.IO2

# Remove autoTerminationPolicy from stepfunctions-tasks EmrCreateClusterProps. This value is not supported by stepfunctions at the moment and was not supported in the past.
removed:@aws-cdk/aws-stepfunctions-tasks.EmrCreateCluster.AutoTerminationPolicyProperty
removed:@aws-cdk/aws-stepfunctions-tasks.EmrCreateClusterProps.autoTerminationPolicy
14 changes: 0 additions & 14 deletions packages/@aws-cdk/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,20 +700,6 @@ new tasks.EmrCreateCluster(this, 'Create Cluster', {
});
```

If you want to use an [auto-termination policy](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-auto-termination-policy.html),
you can specify the `autoTerminationPolicy` property. Set the `idleTimeout` as a `Duration` between 60 seconds and 7 days.
`autoTerminationPolicy` requires the EMR release label to be 5.30.0 or above.

```ts
new tasks.EmrCreateCluster(this, 'Create Cluster', {
instances: {},
name: 'ClusterName',
autoTerminationPolicy: {
idleTimeout: Duration.seconds(120),
},
});
```

### Termination Protection

Locks a cluster (job flow) so the EC2 instances in the cluster cannot be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Construct } from 'constructs';
import { integrationResourceArn, validatePatternSupported } from '../private/task-utils';
import {
ApplicationConfigPropertyToJson,
AutoTerminationPolicyPropertyToJson,
BootstrapActionConfigToJson,
ConfigurationPropertyToJson,
InstancesConfigPropertyToJson,
Expand Down Expand Up @@ -68,15 +67,6 @@ export interface EmrCreateClusterProps extends sfn.TaskStateBaseProps {
*/
readonly autoScalingRole?: iam.IRole;

/**
* An auto-termination policy for an Amazon EMR cluster. An auto-termination policy defines the amount of
* idle time in seconds after which a cluster automatically terminates. The value must be between
* 60 seconds and 7 days.
*
* @default - None
*/
readonly autoTerminationPolicy?: EmrCreateCluster.AutoTerminationPolicyProperty;

/**
* A list of bootstrap actions to run before Hadoop starts on the cluster nodes.
*
Expand Down Expand Up @@ -279,7 +269,6 @@ export class EmrCreateCluster extends sfn.TaskStateBase {
AdditionalInfo: cdk.stringToCloudFormation(this.props.additionalInfo),
Applications: cdk.listMapper(ApplicationConfigPropertyToJson)(this.props.applications),
AutoScalingRole: cdk.stringToCloudFormation(this._autoScalingRole?.roleName),
AutoTerminationPolicy: this.props.autoTerminationPolicy ? AutoTerminationPolicyPropertyToJson(this.props.autoTerminationPolicy) : undefined,
BootstrapActions: cdk.listMapper(BootstrapActionConfigToJson)(this.props.bootstrapActions),
Configurations: cdk.listMapper(ConfigurationPropertyToJson)(this.props.configurations),
CustomAmiId: cdk.stringToCloudFormation(this.props.customAmiId),
Expand Down Expand Up @@ -1400,20 +1389,6 @@ export namespace EmrCreateCluster {
readonly version?: string;
}

/**
* Auto-termination policy for the EMR cluster.
*
* @see https://docs.aws.amazon.com/emr/latest/APIReference/API_AutoTerminationPolicy.html
*
*/
export interface AutoTerminationPolicyProperty {

/**
* Specifies the amount of idle time after which the cluster automatically terminates.
*/
readonly idleTimeout: cdk.Duration;
}

/**
* Configuration of the script to run during a bootstrap action.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { EmrModifyInstanceGroupByName } from '../emr-modify-instance-group-by-na

/**
* Render the KerberosAttributesProperty as JSON
*
* @param property
*/
export function KerberosAttributesPropertyToJson(property: EmrCreateCluster.KerberosAttributesProperty) {
return {
Expand All @@ -17,6 +19,8 @@ export function KerberosAttributesPropertyToJson(property: EmrCreateCluster.Kerb

/**
* Render the InstancesConfigProperty to JSON
*
* @param property
*/
export function InstancesConfigPropertyToJson(property: EmrCreateCluster.InstancesConfigProperty) {
return {
Expand All @@ -42,6 +46,8 @@ export function InstancesConfigPropertyToJson(property: EmrCreateCluster.Instanc

/**
* Render the ApplicationConfigProperty as JSON
*
* @param property
*/
export function ApplicationConfigPropertyToJson(property: EmrCreateCluster.ApplicationConfigProperty) {
return {
Expand All @@ -52,17 +58,10 @@ export function ApplicationConfigPropertyToJson(property: EmrCreateCluster.Appli
};
}

/**
* Render the AutoTerminationPolicyProperty as JSON
*/
export function AutoTerminationPolicyPropertyToJson(property: EmrCreateCluster.AutoTerminationPolicyProperty) {
return {
IdleTimeout: cdk.numberToCloudFormation(property.idleTimeout.toSeconds()),
};
}

/**
* Render the ConfigurationProperty as JSON
*
* @param property
*/
export function ConfigurationPropertyToJson(property: EmrCreateCluster.ConfigurationProperty) {
return {
Expand All @@ -74,6 +73,8 @@ export function ConfigurationPropertyToJson(property: EmrCreateCluster.Configura

/**
* Render the EbsBlockDeviceConfigProperty as JSON
*
* @param property
*/
export function EbsBlockDeviceConfigPropertyToJson(property: EmrCreateCluster.EbsBlockDeviceConfigProperty) {
return {
Expand All @@ -88,6 +89,8 @@ export function EbsBlockDeviceConfigPropertyToJson(property: EmrCreateCluster.Eb

/**
* Render the EbsConfigurationProperty to JSON
*
* @param property
*/
export function EbsConfigurationPropertyToJson(property: EmrCreateCluster.EbsConfigurationProperty) {
return {
Expand All @@ -114,6 +117,8 @@ export function InstanceTypeConfigPropertyToJson(property: EmrCreateCluster.Inst

/**
* Render the InstanceFleetProvisioningSpecificationsProperty to JSON
*
* @param property
*/
export function InstanceFleetProvisioningSpecificationsPropertyToJson(property: EmrCreateCluster.InstanceFleetProvisioningSpecificationsProperty) {
return {
Expand All @@ -128,6 +133,8 @@ export function InstanceFleetProvisioningSpecificationsPropertyToJson(property:

/**
* Render the InstanceFleetConfigProperty as JSON
*
* @param property
*/
export function InstanceFleetConfigPropertyToJson(property: EmrCreateCluster.InstanceFleetConfigProperty) {
return {
Expand All @@ -145,6 +152,8 @@ export function InstanceFleetConfigPropertyToJson(property: EmrCreateCluster.Ins

/**
* Render the MetricDimensionProperty as JSON
*
* @param property
*/
export function MetricDimensionPropertyToJson(property: EmrCreateCluster.MetricDimensionProperty) {
return {
Expand All @@ -155,6 +164,8 @@ export function MetricDimensionPropertyToJson(property: EmrCreateCluster.MetricD

/**
* Render the ScalingTriggerProperty to JSON
*
* @param property
*/
export function ScalingTriggerPropertyToJson(property: EmrCreateCluster.ScalingTriggerProperty) {
return {
Expand All @@ -174,6 +185,8 @@ export function ScalingTriggerPropertyToJson(property: EmrCreateCluster.ScalingT

/**
* Render the ScalingActionProperty to JSON
*
* @param property
*/
export function ScalingActionPropertyToJson(property: EmrCreateCluster.ScalingActionProperty) {
return {
Expand All @@ -188,6 +201,8 @@ export function ScalingActionPropertyToJson(property: EmrCreateCluster.ScalingAc

/**
* Render the ScalingRuleProperty to JSON
*
* @param property
*/
export function ScalingRulePropertyToJson(property: EmrCreateCluster.ScalingRuleProperty) {
return {
Expand All @@ -200,6 +215,8 @@ export function ScalingRulePropertyToJson(property: EmrCreateCluster.ScalingRule

/**
* Render the AutoScalingPolicyProperty to JSON
*
* @param property
*/
export function AutoScalingPolicyPropertyToJson(property: EmrCreateCluster.AutoScalingPolicyProperty) {
return {
Expand All @@ -213,6 +230,8 @@ export function AutoScalingPolicyPropertyToJson(property: EmrCreateCluster.AutoS

/**
* Render the InstanceGroupConfigProperty to JSON
*
* @param property
*/
export function InstanceGroupConfigPropertyToJson(property: EmrCreateCluster.InstanceGroupConfigProperty) {
return {
Expand All @@ -231,6 +250,8 @@ export function InstanceGroupConfigPropertyToJson(property: EmrCreateCluster.Ins

/**
* Render the PlacementTypeProperty to JSON
*
* @param property
*/
export function PlacementTypePropertyToJson(property: EmrCreateCluster.PlacementTypeProperty) {
return {
Expand All @@ -241,6 +262,8 @@ export function PlacementTypePropertyToJson(property: EmrCreateCluster.Placement

/**
* Render the BootstrapActionProperty as JSON
*
* @param property
*/
export function BootstrapActionConfigToJson(property: EmrCreateCluster.BootstrapActionConfigProperty) {
return {
Expand All @@ -254,6 +277,8 @@ export function BootstrapActionConfigToJson(property: EmrCreateCluster.Bootstrap

/**
* Render the InstanceGroupModifyConfigProperty to JSON
*
* @param property
*/
export function InstanceGroupModifyConfigPropertyToJson(property: EmrModifyInstanceGroupByName.InstanceGroupModifyConfigProperty) {
return {
Expand All @@ -266,6 +291,8 @@ export function InstanceGroupModifyConfigPropertyToJson(property: EmrModifyInsta

/**
* Render the ShrinkPolicyProperty to JSON
*
* @param property
*/
function ShrinkPolicyPropertyToJson(property: EmrModifyInstanceGroupByName.ShrinkPolicyProperty) {
return {
Expand All @@ -276,6 +303,8 @@ function ShrinkPolicyPropertyToJson(property: EmrModifyInstanceGroupByName.Shrin

/**
* Render the InstanceResizePolicyProperty to JSON
*
* @param property
*/
function InstanceResizePolicyPropertyToJson(property: EmrModifyInstanceGroupByName.InstanceResizePolicyProperty) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,58 +864,6 @@ test('Create Cluster with InstanceFleet with allocation strategy=capacity-optimi
});
});

test('Create Cluster with AutoTerminationPolicy', () => {
// WHEN
const task = new EmrCreateCluster(stack, 'Task', {
instances: {},
clusterRole,
name: 'Cluster',
serviceRole,
autoScalingRole,
autoTerminationPolicy: {
idleTimeout: cdk.Duration.seconds(120),
},
integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE,
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::elasticmapreduce:createCluster',
],
],
},
End: true,
Parameters: {
Name: 'Cluster',
Instances: {
KeepJobFlowAliveWhenNoSteps: true,
},
VisibleToAllUsers: true,
JobFlowRole: {
Ref: 'ClusterRoleD9CA7471',
},
ServiceRole: {
Ref: 'ServiceRole4288B192',
},
AutoScalingRole: {
Ref: 'AutoScalingRole015ADA0A',
},
AutoTerminationPolicy: {
IdleTimeout: 120,
},
},
});
});

test('Create Cluster with InstanceFleet', () => {
// WHEN
const task = new EmrCreateCluster(stack, 'Task', {
Expand Down

0 comments on commit 876eb84

Please sign in to comment.