New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stepfunctions-tasks): add AutoTerminationPolicy.IdleTimeout to EmrCreateCluster #29954
base: main
Are you sure you want to change the base?
Changes from 2 commits
db4799f
c194e7d
9f48f4e
5212bd3
39191b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,17 @@ export function ApplicationConfigPropertyToJson(property: EmrCreateCluster.Appli | |
}; | ||
} | ||
|
||
/** | ||
* Render the AutoTerminationPolicyProperty as JSON | ||
* | ||
* @param property | ||
*/ | ||
export function AutoTerminationPolicyPropertyToJson(property: EmrCreateCluster.AutoTerminationPolicyProperty) { | ||
return { | ||
IdleTimeout: cdk.numberToCloudFormation(property.idleTimeout.toSeconds()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IdleTimeout is an optional property in cloudformation. In that case shouldn't we handle it as optional? |
||
}; | ||
} | ||
|
||
/** | ||
* Render the ConfigurationProperty as JSON | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1733,3 +1733,55 @@ test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration patt | |
}); | ||
}).toThrow(/Unsupported service integration pattern. Supported Patterns: REQUEST_RESPONSE,RUN_JOB. Received: WAIT_FOR_TASK_TOKEN/); | ||
}); | ||
|
||
test('Create Cluster with AutoTerminationPolicy', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also add a test to throw error when the IdleTimeout is given outside the accepted seconds? |
||
// 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, | ||
}, | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this property needs to be optional?