SetTerminationProtection locks a cluster (job flow) so the Amazon EC2 instances in the cluster cannot be terminated by user intervention, an API call, or in the event of a job-flow error. The cluster still terminates upon successful completion of the job flow. Calling SetTerminationProtection on a cluster is similar to calling the Amazon EC2 DisableAPITermination API on all Amazon EC2 instances in a cluster.
SetTerminationProtection is used to prevent accidental termination of a cluster and to ensure that in the event of an error, the instances persist so that you can recover any data stored in their ephemeral instance storage.
To terminate a cluster that has been locked by setting SetTerminationProtection to true, you must first unlock the job flow by a subsequent call to SetTerminationProtection in which you set the value to false.
For more information, see Managing Cluster Termination in the Amazon EMR Management Guide.
Parameters:
-
job_flow_ids
(Optional[XmlStringList], default:
None
)
–
A list of strings that uniquely identify the clusters to protect. This identifier is returned by RunJobFlow and can also be obtained from DescribeJobFlows .
-
termination_protected
(Optional[Boolean], default:
None
)
–
A Boolean that indicates whether to protect the cluster and prevent the Amazon EC2 instances in the cluster from shutting down due to API calls, user intervention, or job-flow error.
Raises:
-
InternalServerError
–
Indicates that an error occurred while processing the request and that the request was not completed.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_emr/_services/emr.py
| def set_termination_protection(
self,
*,
config_overrides: Optional[EMRClientConfig] = None,
job_flow_ids: Optional["capo_emr.types.xml_string_list.XmlStringList"] = None,
termination_protected: Optional["capo_emr.types.boolean.Boolean"] = None,
) -> None:
"""<p>SetTerminationProtection locks a cluster (job flow) so the Amazon EC2 instances in the cluster cannot be terminated by user intervention, an API call, or in the event of a job-flow error. The cluster still terminates upon successful completion of the job flow. Calling <code>SetTerminationProtection</code> on a cluster is similar to calling the Amazon EC2 <code>DisableAPITermination</code> API on all Amazon EC2 instances in a cluster.</p> <p> <code>SetTerminationProtection</code> is used to prevent accidental termination of a cluster and to ensure that in the event of an error, the instances persist so that you can recover any data stored in their ephemeral instance storage.</p> <p> To terminate a cluster that has been locked by setting <code>SetTerminationProtection</code> to <code>true</code>, you must first unlock the job flow by a subsequent call to <code>SetTerminationProtection</code> in which you set the value to <code>false</code>. </p> <p> For more information, see <a href="https://docs.aws.amazon.com/emr/latest/ManagementGuide/UsingEMR_TerminationProtection.html">Managing Cluster Termination</a> in the <i>Amazon EMR Management Guide</i>. </p>
Args:
job_flow_ids: <p> A list of strings that uniquely identify the clusters to protect. This identifier is returned by <a>RunJobFlow</a> and can also be obtained from <a>DescribeJobFlows</a> . </p>
termination_protected: <p>A Boolean that indicates whether to protect the cluster and prevent the Amazon EC2 instances in the cluster from shutting down due to API calls, user intervention, or job-flow error.</p>
Raises:
capo_emr.errors.internal_server_error.InternalServerError: <p>Indicates that an error occurred while processing the request and that the request was not completed.</p>
capo_emr.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_emr.types.set_termination_protection_input.SetTerminationProtectionInput]",
) -> OperationResponse[None]:
import capo_emr._operations.elastic_map_reduce.set_termination_protection
output, http_response = (
capo_emr._operations.elastic_map_reduce.set_termination_protection.set_termination_protection(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("SetTerminationProtection")
)
input_: capo_emr.types.set_termination_protection_input.SetTerminationProtectionInput = {}
if job_flow_ids is not None:
input_["job_flow_ids"] = job_flow_ids
if termination_protected is not None:
input_["termination_protected"] = termination_protected
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|