Skip to content

rollback_stack

rollback_stack(
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    stack_name: Optional[StackNameOrId] = None,
    role_arn: Optional[RoleARN] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    retain_except_on_create: Optional[RetainExceptOnCreate] = None,
    deployment_config: Optional[DeploymentConfig] = None,
) -> RollbackStackOutput

When specifying RollbackStack, you preserve the state of previously provisioned resources when an operation fails. You can check the status of the stack through the DescribeStacks operation.

Rolls back the specified stack to the last known stable state from CREATE_FAILED or UPDATE_FAILED stack statuses.

This operation will delete a stack if it doesn't contain a last known stable state. A last known stable state includes any status in a *_COMPLETE. This includes the following stack statuses.

  • CREATE_COMPLETE

  • UPDATE_COMPLETE

  • UPDATE_ROLLBACK_COMPLETE

  • IMPORT_COMPLETE

  • IMPORT_ROLLBACK_COMPLETE

Parameters:

  • stack_name (Optional[StackNameOrId], default: None ) –

    The name that's associated with the stack.

  • role_arn (Optional[RoleARN], default: None ) –

    The Amazon Resource Name (ARN) of an IAM role that CloudFormation assumes to rollback the stack.

  • client_request_token (Optional[ClientRequestToken], default: None ) –

    A unique identifier for this RollbackStack request.

  • retain_except_on_create (Optional[RetainExceptOnCreate], default: None ) –

    When set to true, newly created resources are deleted when the operation rolls back. This includes newly created resources marked with a deletion policy of Retain.

    Default: false

  • deployment_config (Optional[DeploymentConfig], default: None ) –

    The deployment configuration for this stack operation, including the deployment mode.

Raises:

Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
def rollback_stack(
    self,
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    stack_name: Optional[
        "capo_cloudformation.types.stack_name_or_id.StackNameOrId"
    ] = None,
    role_arn: Optional["capo_cloudformation.types.role_arn.RoleARN"] = None,
    client_request_token: Optional[
        "capo_cloudformation.types.client_request_token.ClientRequestToken"
    ] = None,
    retain_except_on_create: Optional[
        "capo_cloudformation.types.retain_except_on_create.RetainExceptOnCreate"
    ] = None,
    deployment_config: Optional[
        "capo_cloudformation.types.deployment_config.DeploymentConfig"
    ] = None,
) -> "capo_cloudformation.types.rollback_stack_output.RollbackStackOutput":
    """<p>When specifying <code>RollbackStack</code>, you preserve the state of previously provisioned resources when an operation fails. You can check the status of the stack through the <a>DescribeStacks</a> operation.</p> <p>Rolls back the specified stack to the last known stable state from <code>CREATE_FAILED</code> or <code>UPDATE_FAILED</code> stack statuses.</p> <p>This operation will delete a stack if it doesn't contain a last known stable state. A last known stable state includes any status in a <code>*_COMPLETE</code>. This includes the following stack statuses.</p> <ul> <li> <p> <code>CREATE_COMPLETE</code> </p> </li> <li> <p> <code>UPDATE_COMPLETE</code> </p> </li> <li> <p> <code>UPDATE_ROLLBACK_COMPLETE</code> </p> </li> <li> <p> <code>IMPORT_COMPLETE</code> </p> </li> <li> <p> <code>IMPORT_ROLLBACK_COMPLETE</code> </p> </li> </ul>

    Args:
        stack_name: <p>The name that's associated with the stack.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of an IAM role that CloudFormation assumes to rollback the stack.</p>
        client_request_token: <p>A unique identifier for this <code>RollbackStack</code> request.</p>
        retain_except_on_create: <p>When set to <code>true</code>, newly created resources are deleted when the operation rolls back. This includes newly created resources marked with a deletion policy of <code>Retain</code>.</p> <p>Default: <code>false</code> </p>
        deployment_config: <p>The deployment configuration for this stack operation, including the deployment mode.</p>

    Raises:
        capo_cloudformation.errors.token_already_exists_exception.TokenAlreadyExistsException: <p>A client request token already exists.</p>
        capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudformation.types.rollback_stack_input.RollbackStackInput]",
    ) -> OperationResponse[
        "capo_cloudformation.types.rollback_stack_output.RollbackStackOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.rollback_stack

        output, http_response = (
            capo_cloudformation._operations.cloud_formation.rollback_stack.rollback_stack(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RollbackStack")
    )
    input_: capo_cloudformation.types.rollback_stack_input.RollbackStackInput = {}
    if stack_name is not None:
        input_["stack_name"] = stack_name
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if client_request_token is not None:
        input_["client_request_token"] = client_request_token
    if retain_except_on_create is not None:
        input_["retain_except_on_create"] = retain_except_on_create
    if deployment_config is not None:
        input_["deployment_config"] = deployment_config

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output