Skip to content

execute_change_set

execute_change_set(
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    change_set_name: Optional[ChangeSetNameOrId] = None,
    stack_name: Optional[StackNameOrId] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    disable_rollback: Optional[DisableRollback] = None,
    retain_except_on_create: Optional[RetainExceptOnCreate] = None,
) -> ExecuteChangeSetOutput

Updates a stack using the input information that was provided when the specified change set was created. After the call successfully completes, CloudFormation starts updating the stack. Use the DescribeStacks action to view the status of the update.

When you execute a change set, CloudFormation deletes all other change sets associated with the stack because they aren't valid for the updated stack.

If a stack policy is associated with the stack, CloudFormation enforces the policy during the update. You can't specify a temporary stack policy that overrides the current policy.

To create a change set for the entire stack hierarchy, IncludeNestedStacks must have been set to True.

Parameters:

  • change_set_name (Optional[ChangeSetNameOrId], default: None ) –

    The name or Amazon Resource Name (ARN) of the change set that you want use to update the specified stack.

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

    If you specified the name of a change set, specify the stack name or Amazon Resource Name (ARN) that's associated with the change set you want to execute.

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

    A unique identifier for this ExecuteChangeSet request. Specify this token if you plan to retry requests so that CloudFormation knows that you're not attempting to execute a change set to update a stack with the same name. You might retry ExecuteChangeSet requests to ensure that CloudFormation successfully received them.

  • disable_rollback (Optional[DisableRollback], default: None ) –

    Preserves the state of previously provisioned resources when an operation fails. This parameter can't be specified when the OnStackFailure parameter to the CreateChangeSet API operation was specified.

    • True - if the stack creation fails, do nothing. This is equivalent to specifying DO_NOTHING for the OnStackFailure parameter to the CreateChangeSet API operation.

    • False - if the stack creation fails, roll back the stack. This is equivalent to specifying ROLLBACK for the OnStackFailure parameter to the CreateChangeSet API operation.

    Default: True

  • 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

Raises:

Source code in docs_src/capo_cloudformation/_services/cloud_formation.py
def execute_change_set(
    self,
    *,
    config_overrides: Optional[CloudFormationClientConfig] = None,
    change_set_name: Optional[
        "capo_cloudformation.types.change_set_name_or_id.ChangeSetNameOrId"
    ] = None,
    stack_name: Optional[
        "capo_cloudformation.types.stack_name_or_id.StackNameOrId"
    ] = None,
    client_request_token: Optional[
        "capo_cloudformation.types.client_request_token.ClientRequestToken"
    ] = None,
    disable_rollback: Optional[
        "capo_cloudformation.types.disable_rollback.DisableRollback"
    ] = None,
    retain_except_on_create: Optional[
        "capo_cloudformation.types.retain_except_on_create.RetainExceptOnCreate"
    ] = None,
) -> "capo_cloudformation.types.execute_change_set_output.ExecuteChangeSetOutput":
    """<p>Updates a stack using the input information that was provided when the specified change set was created. After the call successfully completes, CloudFormation starts updating the stack. Use the <a>DescribeStacks</a> action to view the status of the update.</p> <p>When you execute a change set, CloudFormation deletes all other change sets associated with the stack because they aren't valid for the updated stack.</p> <p>If a stack policy is associated with the stack, CloudFormation enforces the policy during the update. You can't specify a temporary stack policy that overrides the current policy.</p> <p>To create a change set for the entire stack hierarchy, <code>IncludeNestedStacks</code> must have been set to <code>True</code>.</p>

    Args:
        change_set_name: <p>The name or Amazon Resource Name (ARN) of the change set that you want use to update the specified stack.</p>
        stack_name: <p>If you specified the name of a change set, specify the stack name or Amazon Resource Name (ARN) that's associated with the change set you want to execute.</p>
        client_request_token: <p>A unique identifier for this <code>ExecuteChangeSet</code> request. Specify this token if you plan to retry requests so that CloudFormation knows that you're not attempting to execute a change set to update a stack with the same name. You might retry <code>ExecuteChangeSet</code> requests to ensure that CloudFormation successfully received them.</p>
        disable_rollback: <p>Preserves the state of previously provisioned resources when an operation fails. This parameter can't be specified when the <code>OnStackFailure</code> parameter to the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html">CreateChangeSet</a> API operation was specified.</p> <ul> <li> <p> <code>True</code> - if the stack creation fails, do nothing. This is equivalent to specifying <code>DO_NOTHING</code> for the <code>OnStackFailure</code> parameter to the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html">CreateChangeSet</a> API operation.</p> </li> <li> <p> <code>False</code> - if the stack creation fails, roll back the stack. This is equivalent to specifying <code>ROLLBACK</code> for the <code>OnStackFailure</code> parameter to the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html">CreateChangeSet</a> API operation.</p> </li> </ul> <p>Default: <code>True</code> </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>

    Raises:
        capo_cloudformation.errors.change_set_not_found_exception.ChangeSetNotFoundException: <p>The specified change set name or ID doesn't exit. To view valid change sets for a stack, use the <code>ListChangeSets</code> operation.</p>
        capo_cloudformation.errors.insufficient_capabilities_exception.InsufficientCapabilitiesException: <p>The template contains resources with capabilities that weren't specified in the Capabilities parameter.</p>
        capo_cloudformation.errors.invalid_change_set_status_exception.InvalidChangeSetStatusException: <p>The specified change set can't be used to update the stack. For example, the change set status might be <code>CREATE_IN_PROGRESS</code>, or the stack status might be <code>UPDATE_IN_PROGRESS</code>.</p>
        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.execute_change_set_input.ExecuteChangeSetInput]",
    ) -> OperationResponse[
        "capo_cloudformation.types.execute_change_set_output.ExecuteChangeSetOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.execute_change_set

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ExecuteChangeSet")
    )
    input_: capo_cloudformation.types.execute_change_set_input.ExecuteChangeSetInput = {}
    if change_set_name is not None:
        input_["change_set_name"] = change_set_name
    if stack_name is not None:
        input_["stack_name"] = stack_name
    if client_request_token is not None:
        input_["client_request_token"] = client_request_token
    if disable_rollback is not None:
        input_["disable_rollback"] = disable_rollback
    if retain_except_on_create is not None:
        input_["retain_except_on_create"] = retain_except_on_create

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