Updates termination protection for the specified stack. If a user attempts to delete a stack with termination protection enabled, the operation fails and the stack remains unchanged. For more information, see Protect a CloudFormation stack from being deleted in the CloudFormation User Guide.
For nested stacks, termination protection is set on the root stack and can't be changed directly on the nested stack.
Parameters:
-
enable_termination_protection
(Optional[EnableTerminationProtection], default:
None
)
–
Whether to enable termination protection on the specified stack.
-
stack_name
(Optional[StackNameOrId], default:
None
)
–
The name or unique ID of the stack for which you want to set termination protection.
Raises:
Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
| def update_termination_protection(
self,
*,
config_overrides: Optional[CloudFormationClientConfig] = None,
enable_termination_protection: Optional[
"capo_cloudformation.types.enable_termination_protection.EnableTerminationProtection"
] = None,
stack_name: Optional[
"capo_cloudformation.types.stack_name_or_id.StackNameOrId"
] = None,
) -> "capo_cloudformation.types.update_termination_protection_output.UpdateTerminationProtectionOutput":
"""<p>Updates termination protection for the specified stack. If a user attempts to delete a stack with termination protection enabled, the operation fails and the stack remains unchanged. For more information, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-protect-stacks.html">Protect a CloudFormation stack from being deleted</a> in the <i>CloudFormation User Guide</i>.</p> <p>For <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html">nested stacks</a>, termination protection is set on the root stack and can't be changed directly on the nested stack.</p>
Args:
enable_termination_protection: <p>Whether to enable termination protection on the specified stack.</p>
stack_name: <p>The name or unique ID of the stack for which you want to set termination protection.</p>
Raises:
capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudformation.types.update_termination_protection_input.UpdateTerminationProtectionInput]",
) -> OperationResponse[
"capo_cloudformation.types.update_termination_protection_output.UpdateTerminationProtectionOutput"
]:
import capo_cloudformation._operations.cloud_formation.update_termination_protection
output, http_response = (
capo_cloudformation._operations.cloud_formation.update_termination_protection.update_termination_protection(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("UpdateTerminationProtection")
)
input_: capo_cloudformation.types.update_termination_protection_input.UpdateTerminationProtectionInput = {}
if enable_termination_protection is not None:
input_["enable_termination_protection"] = enable_termination_protection
if stack_name is not None:
input_["stack_name"] = stack_name
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|