Skip to content

delete_stack_instances async

delete_stack_instances(
    *,
    config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
    stack_set_name: Optional[StackSetName] = None,
    accounts: Optional[AccountList] = None,
    deployment_targets: Optional[DeploymentTargets] = None,
    regions: Optional[RegionList] = None,
    operation_preferences: Optional[StackSetOperationPreferences] = None,
    retain_stacks: Optional[RetainStacks] = None,
    operation_id: Optional[ClientRequestToken] = None,
    call_as: Optional[CallAs] = None,
) -> DeleteStackInstancesOutput

Deletes stack instances for the specified accounts, in the specified Amazon Web Services Regions.

The maximum number of organizational unit (OUs) supported by a DeleteStackInstances operation is 50.

If you need more than 50, consider the following options:

  • Batch processing: If you don't want to expose your OU hierarchy, split up the operations into multiple calls with less than 50 OUs each.

  • Parent OU strategy: If you don't mind exposing the OU hierarchy, target a parent OU that contains all desired child OUs.

Parameters:

  • stack_set_name (Optional[StackSetName], default: None ) –

    The name or unique ID of the StackSet that you want to delete stack instances for.

  • accounts (Optional[AccountList], default: None ) –

    [Self-managed permissions] The account IDs of the Amazon Web Services accounts that you want to delete stack instances for.

    You can specify Accounts or DeploymentTargets, but not both.

  • deployment_targets (Optional[DeploymentTargets], default: None ) –

    [Service-managed permissions] The Organizations accounts from which to delete stack instances.

    You can specify Accounts or DeploymentTargets, but not both.

  • regions (Optional[RegionList], default: None ) –

    The Amazon Web Services Regions where you want to delete StackSet instances.

  • operation_preferences (Optional[StackSetOperationPreferences], default: None ) –

    Preferences for how CloudFormation performs this StackSet operation.

  • retain_stacks (Optional[RetainStacks], default: None ) –

    Removes the stack instances from the specified StackSet, but doesn't delete the stacks. You can't reassociate a retained stack or add an existing, saved stack to a new stack set.

    For more information, see StackSet operation options.

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

    The unique identifier for this StackSet operation.

    If you don't specify an operation ID, the SDK generates one automatically.

    The operation ID also functions as an idempotency token, to ensure that CloudFormation performs the StackSet operation only once, even if you retry the request multiple times. You can retry StackSet operation requests to ensure that CloudFormation successfully received them.

    Repeating this StackSet operation with a new operation ID retries all stack instances whose status is OUTDATED.

  • call_as (Optional[CallAs], default: None ) –

    [Service-managed permissions] Specifies whether you are acting as an account administrator in the organization's management account or as a delegated administrator in a member account.

    By default, SELF is specified. Use SELF for StackSets with self-managed permissions.

    • If you are signed in to the management account, specify SELF.

    • If you are signed in to a delegated administrator account, specify DELEGATED_ADMIN.

      Your Amazon Web Services account must be registered as a delegated administrator in the management account. For more information, see Register a delegated administrator in the CloudFormation User Guide.

Raises:

Source code in docs_src/capo_cloudformation/_services/async_cloud_formation.py
async def delete_stack_instances(
    self,
    *,
    config_overrides: Optional[AsyncCloudFormationClientConfig] = None,
    stack_set_name: Optional[
        "capo_cloudformation.types.stack_set_name.StackSetName"
    ] = None,
    accounts: Optional["capo_cloudformation.types.account_list.AccountList"] = None,
    deployment_targets: Optional[
        "capo_cloudformation.types.deployment_targets.DeploymentTargets"
    ] = None,
    regions: Optional["capo_cloudformation.types.region_list.RegionList"] = None,
    operation_preferences: Optional[
        "capo_cloudformation.types.stack_set_operation_preferences.StackSetOperationPreferences"
    ] = None,
    retain_stacks: Optional[
        "capo_cloudformation.types.retain_stacks.RetainStacks"
    ] = None,
    operation_id: Optional[
        "capo_cloudformation.types.client_request_token.ClientRequestToken"
    ] = None,
    call_as: Optional["capo_cloudformation.types.call_as.CallAs"] = None,
) -> "capo_cloudformation.types.delete_stack_instances_output.DeleteStackInstancesOutput":
    """<p>Deletes stack instances for the specified accounts, in the specified Amazon Web Services Regions.</p> <note> <p>The maximum number of organizational unit (OUs) supported by a <code>DeleteStackInstances</code> operation is 50.</p> <p>If you need more than 50, consider the following options:</p> <ul> <li> <p> <i>Batch processing:</i> If you don't want to expose your OU hierarchy, split up the operations into multiple calls with less than 50 OUs each.</p> </li> <li> <p> <i>Parent OU strategy:</i> If you don't mind exposing the OU hierarchy, target a parent OU that contains all desired child OUs.</p> </li> </ul> </note>

    Args:
        stack_set_name: <p>The name or unique ID of the StackSet that you want to delete stack instances for.</p>
        accounts: <p>[Self-managed permissions] The account IDs of the Amazon Web Services accounts that you want to delete stack instances for.</p> <p>You can specify <code>Accounts</code> or <code>DeploymentTargets</code>, but not both.</p>
        deployment_targets: <p>[Service-managed permissions] The Organizations accounts from which to delete stack instances.</p> <p>You can specify <code>Accounts</code> or <code>DeploymentTargets</code>, but not both.</p>
        regions: <p>The Amazon Web Services Regions where you want to delete StackSet instances.</p>
        operation_preferences: <p>Preferences for how CloudFormation performs this StackSet operation.</p>
        retain_stacks: <p>Removes the stack instances from the specified StackSet, but doesn't delete the stacks. You can't reassociate a retained stack or add an existing, saved stack to a new stack set.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html#stackset-ops-options">StackSet operation options</a>.</p>
        operation_id: <p>The unique identifier for this StackSet operation.</p> <p>If you don't specify an operation ID, the SDK generates one automatically.</p> <p>The operation ID also functions as an idempotency token, to ensure that CloudFormation performs the StackSet operation only once, even if you retry the request multiple times. You can retry StackSet operation requests to ensure that CloudFormation successfully received them.</p> <p>Repeating this StackSet operation with a new operation ID retries all stack instances whose status is <code>OUTDATED</code>.</p>
        call_as: <p>[Service-managed permissions] Specifies whether you are acting as an account administrator in the organization's management account or as a delegated administrator in a member account.</p> <p>By default, <code>SELF</code> is specified. Use <code>SELF</code> for StackSets with self-managed permissions.</p> <ul> <li> <p>If you are signed in to the management account, specify <code>SELF</code>.</p> </li> <li> <p>If you are signed in to a delegated administrator account, specify <code>DELEGATED_ADMIN</code>.</p> <p>Your Amazon Web Services account must be registered as a delegated administrator in the management account. For more information, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html">Register a delegated administrator</a> in the <i>CloudFormation User Guide</i>.</p> </li> </ul>

    Raises:
        capo_cloudformation.errors.invalid_operation_exception.InvalidOperationException: <p>The specified operation isn't valid.</p>
        capo_cloudformation.errors.operation_id_already_exists_exception.OperationIdAlreadyExistsException: <p>The specified operation ID already exists.</p>
        capo_cloudformation.errors.operation_in_progress_exception.OperationInProgressException: <p>Another operation is currently in progress for this StackSet. Only one operation can be performed for a stack set at a given time.</p>
        capo_cloudformation.errors.stack_set_not_found_exception.StackSetNotFoundException: <p>The specified StackSet doesn't exist.</p>
        capo_cloudformation.errors.stale_request_exception.StaleRequestException: <p>Another operation has been performed on this StackSet since the specified operation was performed.</p>
        capo_cloudformation.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudformation.types.delete_stack_instances_input.DeleteStackInstancesInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudformation.types.delete_stack_instances_output.DeleteStackInstancesOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.delete_stack_instances

        (
            output,
            http_response,
        ) = await capo_cloudformation._operations.cloud_formation.delete_stack_instances.async_delete_stack_instances(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteStackInstances")
    )
    input_: capo_cloudformation.types.delete_stack_instances_input.DeleteStackInstancesInput = {}
    if stack_set_name is not None:
        input_["stack_set_name"] = stack_set_name
    if accounts is not None:
        input_["accounts"] = accounts
    if deployment_targets is not None:
        input_["deployment_targets"] = deployment_targets
    if regions is not None:
        input_["regions"] = regions
    if operation_preferences is not None:
        input_["operation_preferences"] = operation_preferences
    if retain_stacks is not None:
        input_["retain_stacks"] = retain_stacks
    if operation_id is None:
        operation_id = str(uuid.uuid4())
    input_["operation_id"] = operation_id
    if call_as is not None:
        input_["call_as"] = call_as

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output