Skip to content

Commit 2099ea6

Browse files
author
Vikram
authored
Add auto termination policy to EMR (#1818)
1 parent c3c2694 commit 2099ea6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

awswrangler/emr.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def _build_cluster_args(**pars: Any) -> Dict[str, Any]: # pylint: disable=too-m
130130
"StepConcurrencyLevel": pars["step_concurrency_level"],
131131
}
132132

133+
# Auto Termination Policy
134+
if pars["auto_termination_policy"] is not None:
135+
args["AutoTerminationPolicy"] = pars["auto_termination_policy"]
136+
133137
# Custom AMI
134138
if pars["custom_ami_id"] is not None:
135139
args["CustomAmiId"] = pars["custom_ami_id"]
@@ -452,6 +456,7 @@ def create_cluster( # pylint: disable=too-many-arguments,too-many-locals,unused
452456
step_concurrency_level: int = 1,
453457
keep_cluster_alive_when_no_steps: bool = True,
454458
termination_protected: bool = False,
459+
auto_termination_policy: Optional[Dict[str, int]] = None,
455460
tags: Optional[Dict[str, str]] = None,
456461
boto3_session: Optional[boto3.Session] = None,
457462
) -> str:
@@ -604,6 +609,11 @@ def create_cluster( # pylint: disable=too-many-arguments,too-many-locals,unused
604609
Specifies whether the Amazon EC2 instances in the cluster are
605610
protected from termination by API calls, user intervention,
606611
or in the event of a job-flow error.
612+
auto_termination_policy: Optional[Dict[str, int]]
613+
Specifies the auto-termination policy that is attached to an Amazon EMR cluster
614+
eg. auto_termination_policy = {'IdleTimeout': 123}
615+
IdleTimeout specifies the amount of idle time in seconds after which the cluster automatically terminates.
616+
You can specify a minimum of 60 seconds and a maximum of 604800 seconds (seven days).
607617
tags : Dict[str, str], optional
608618
Key/Value collection to put on the Cluster.
609619
e.g. {"foo": "boo", "bar": "xoo"})

0 commit comments

Comments
 (0)