'AWS EMR: Enable auto-termination-policy in cloudformation

I am trying to enable auto termination policy in EMR. Here is the documentation https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-auto-termination-policy.html

I can easily do it via Console, AWS CLI and also using Python SDK (boto3). But I want to enable this in the cloudformation template such that whenever I create an EMR it automatically takes this policy and terminates the cluster if its idle for certain time. Unfortunately I didn't find any documentation for that. In fact I'm not sure if that's even possible or not.



Solution 1:[1]

There is an AutoTerminationPolicy config parameter for the above use case. Something like the following should do the trick:

"AutoTerminationPolicy": {
    "IdleTimeout": 10800, # 3 hours
}

FWIW, this isn't specified anywhere in the user guide documentation. But after some research found it here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Reddy