Skip to content

create_stack_instances async

create_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,
    parameter_overrides: Optional[Parameters] = None,
    operation_preferences: Optional[StackSetOperationPreferences] = None,
    operation_id: Optional[ClientRequestToken] = None,
    call_as: Optional[CallAs] = None,
) -> CreateStackInstancesOutput

Creates stack instances for the specified accounts, within the specified Amazon Web Services Regions. A stack instance refers to a stack in a specific account and Region. You must specify at least one value for either Accounts or DeploymentTargets, and you must specify at least one value for Regions.

The maximum number of organizational unit (OUs) supported by a CreateStackInstances 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 create stack instances from.

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

    [Self-managed permissions] The account IDs of one or more Amazon Web Services accounts that you want to create stack instances in the specified Region(s) for.

    You can specify Accounts or DeploymentTargets, but not both.

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

    [Service-managed permissions] The Organizations accounts in which to create stack instances in the specified Amazon Web Services Regions.

    You can specify Accounts or DeploymentTargets, but not both.

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

    The names of one or more Amazon Web Services Regions where you want to create stack instances using the specified Amazon Web Services accounts.

  • parameter_overrides (Optional[Parameters], default: None ) –

    A list of StackSet parameters whose values you want to override in the selected stack instances.

    Any overridden parameter values will be applied to all stack instances in the specified accounts and Amazon Web Services Regions. When specifying parameters and their values, be aware of how CloudFormation sets parameter values during stack instance operations:

    • To override the current value for a parameter, include the parameter and specify its value.

    • To leave an overridden parameter set to its present value, include the parameter and specify UsePreviousValue as true. (You can't specify both a value and set UsePreviousValue to true.)

    • To set an overridden parameter back to the value specified in the StackSet, specify a parameter list but don't include the parameter in the list.

    • To leave all parameters set to their present values, don't specify this property at all.

    During StackSet updates, any parameter values overridden for a stack instance aren't updated, but retain their overridden value.

    You can only override the parameter values that are specified in the StackSet; to add or delete a parameter itself, use UpdateStackSet to update the StackSet template.

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

    Preferences for how CloudFormation performs this StackSet operation.

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

    The unique identifier for this StackSet operation.

    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 might retry StackSet operation requests to ensure that CloudFormation successfully received them.

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

    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 create_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,
    parameter_overrides: Optional[
        "capo_cloudformation.types.parameters.Parameters"
    ] = None,
    operation_preferences: Optional[
        "capo_cloudformation.types.stack_set_operation_preferences.StackSetOperationPreferences"
    ] = 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.create_stack_instances_output.CreateStackInstancesOutput":
    """<p>Creates stack instances for the specified accounts, within the specified Amazon Web Services Regions. A stack instance refers to a stack in a specific account and Region. You must specify at least one value for either <code>Accounts</code> or <code>DeploymentTargets</code>, and you must specify at least one value for <code>Regions</code>.</p> <note> <p>The maximum number of organizational unit (OUs) supported by a <code>CreateStackInstances</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 create stack instances from.</p>
        accounts: <p>[Self-managed permissions] The account IDs of one or more Amazon Web Services accounts that you want to create stack instances in the specified Region(s) 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 in which to create stack instances in the specified Amazon Web Services Regions.</p> <p>You can specify <code>Accounts</code> or <code>DeploymentTargets</code>, but not both.</p>
        regions: <p>The names of one or more Amazon Web Services Regions where you want to create stack instances using the specified Amazon Web Services accounts.</p>
        parameter_overrides: <p>A list of StackSet parameters whose values you want to override in the selected stack instances.</p> <p>Any overridden parameter values will be applied to all stack instances in the specified accounts and Amazon Web Services Regions. When specifying parameters and their values, be aware of how CloudFormation sets parameter values during stack instance operations:</p> <ul> <li> <p>To override the current value for a parameter, include the parameter and specify its value.</p> </li> <li> <p>To leave an overridden parameter set to its present value, include the parameter and specify <code>UsePreviousValue</code> as <code>true</code>. (You can't specify both a value and set <code>UsePreviousValue</code> to <code>true</code>.)</p> </li> <li> <p>To set an overridden parameter back to the value specified in the StackSet, specify a parameter list but don't include the parameter in the list.</p> </li> <li> <p>To leave all parameters set to their present values, don't specify this property at all.</p> </li> </ul> <p>During StackSet updates, any parameter values overridden for a stack instance aren't updated, but retain their overridden value.</p> <p>You can only override the parameter <i>values</i> that are specified in the StackSet; to add or delete a parameter itself, use <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_UpdateStackSet.html">UpdateStackSet</a> to update the StackSet template.</p>
        operation_preferences: <p>Preferences for how CloudFormation performs this StackSet operation.</p>
        operation_id: <p>The unique identifier for this StackSet operation.</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 might retry StackSet operation requests to ensure that CloudFormation successfully received them.</p> <p>If you don't specify an operation ID, the SDK generates one automatically.</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.limit_exceeded_exception.LimitExceededException: <p>The quota for the resource has already been reached.</p> <p>For information about resource and stack limitations, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html">CloudFormation quotas</a> in the <i>CloudFormation User Guide</i>.</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.create_stack_instances_input.CreateStackInstancesInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudformation.types.create_stack_instances_output.CreateStackInstancesOutput"
    ]:
        import capo_cloudformation._operations.cloud_formation.create_stack_instances

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateStackInstances")
    )
    input_: capo_cloudformation.types.create_stack_instances_input.CreateStackInstancesInput = {}
    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 parameter_overrides is not None:
        input_["parameter_overrides"] = parameter_overrides
    if operation_preferences is not None:
        input_["operation_preferences"] = operation_preferences
    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