Skip to main content

stack_instances

Creates, updates, deletes, gets or lists a stack_instances resource.

Overview

Namestack_instances
TypeResource
Idaws.cloudformation.stack_instances

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
accountstring[Self-managed permissions] The name of the Amazon Web Services account that the stack instance is associated with.
drift_statusstringStatus of the stack instance's actual configuration compared to the expected template and parameter configuration of the StackSet it belongs to. DRIFTED: The stack differs from the expected template and parameter configuration of the StackSet it belongs to. A stack instance is considered to have drifted if one or more of the resources in the associated stack have drifted. NOT_CHECKED: CloudFormation hasn't checked if the stack instance differs from its expected StackSet configuration. IN_SYNC: The stack instance's actual configuration matches its expected StackSset configuration. UNKNOWN: This value is reserved for future use.
last_drift_check_timestampstringMost recent time when CloudFormation performed a drift detection operation on the stack instance. This value will be NULL for any stack instance that drift detection hasn't yet been performed on.
last_operation_idstringThe last unique ID of a StackSet operation performed on a stack instance.
organizational_unit_idstring[Service-managed permissions] The organization root ID or organizational unit (OU) IDs that you specified for DeploymentTargets.
parameter_overridesstringA list of parameters from the StackSet template whose values have been overridden in this stack instance.
regionstringThe name of the Amazon Web Services Region that the stack instance is associated with.
stack_idstringThe ID of the stack instance.
stack_instance_statusstringThe detailed status of the stack instance.
stack_set_idstringThe name or unique ID of the StackSet that the stack instance is associated with.
statusstringThe status of the stack instance, in terms of its synchronization with its associated stack set. INOPERABLE: A DeleteStackInstances operation has failed and left the stack in an unstable state. Stacks in this state are excluded from further UpdateStackSet operations. You might need to perform a DeleteStackInstances operation, with RetainStacks set to true, to delete the stack instance, and then delete the stack manually. INOPERABLE can be returned here when the cause is a failed import. If it's due to a failed import, the operation can be retried once the failures are fixed. To see if this is due to a failed import, look at the DetailedStatus member in the StackInstanceSummary member that is a peer to this Status member. OUTDATED: The stack isn't currently up to date with the StackSet because: The associated stack failed during a CreateStackSet or UpdateStackSet operation. The stack was part of a CreateStackSet or UpdateStackSet operation that failed or was stopped before the stack was created or updated. CURRENT: The stack is currently up to date with the StackSet.
status_reasonstringThe explanation for the specific status code that's assigned to this stack instance.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_stack_instanceselectStackSetName, StackInstanceAccount, StackInstanceRegion, regionCallAsReturns the stack instance that's associated with the specified StackSet, Amazon Web Services account, and Amazon Web Services Region. For a list of stack instances that are associated with a specific StackSet, use ListStackInstances.
list_stack_instancesselectStackSetName, regionNextToken, MaxResults, Filters, StackInstanceAccount, StackInstanceRegion, CallAsReturns summary information about stack instances that are associated with the specified StackSet. You can filter for stack instances that are associated with a specific Amazon Web Services account name or Region, or that have a specific status.
create_stack_instancesinsertStackSetName, regionAccounts, DeploymentTargets, Regions, ParameterOverrides, OperationPreferences, OperationId, CallAsCreates 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.
update_stack_instancesupdateStackSetName, regionAccounts, DeploymentTargets, Regions, ParameterOverrides, OperationPreferences, OperationId, CallAsUpdates the parameter values for 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 can only update stack instances in Amazon Web Services Regions and accounts where they already exist; to create additional stack instances, use CreateStackInstances. During StackSet updates, any parameters overridden for a stack instance aren't updated, but retain their overridden value. You can only update the parameter values that are specified in the StackSet. To add or delete a parameter itself, use UpdateStackSet to update the StackSet template. If you add a parameter to a template, before you can override the parameter value specified in the StackSet you must first use UpdateStackSet to update all stack instances with the updated template and parameter value specified in the StackSet. Once a stack instance has been updated with the new parameter, you can then override the parameter value using UpdateStackInstances. The maximum number of organizational unit (OUs) supported by a UpdateStackInstances 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.
delete_stack_instancesdeleteStackSetName, RetainStacks, regionAccounts, DeploymentTargets, Regions, OperationPreferences, OperationId, CallAsDeletes 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

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
RetainStacksbooleanRemoves 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.
StackInstanceAccountstringThe ID of an Amazon Web Services account that's associated with this stack instance.
StackInstanceRegionstringThe name of a Region that's associated with this stack instance.
StackSetNamestringThe name or unique ID of the StackSet that you want to delete stack instances for.
regionstringAWS region (default: us-east-1)
Accountsarray[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.
CallAsstring[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.
DeploymentTargetsobject[Service-managed permissions] The Organizations accounts from which to delete stack instances. You can specify Accounts or DeploymentTargets, but not both.
FiltersarrayThe filter to apply to stack instances
MaxResultsintegerThe maximum number of results to be returned with a single call. If the number of available results exceeds this maximum, the response includes a NextToken value that you can assign to the NextToken request parameter to get the next set of results.
NextTokenstringThe token for the next set of items to return. (You received this token from a previous call.)
OperationIdstringThe 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.
OperationPreferencesobjectPreferences for how CloudFormation performs this StackSet operation.
ParameterOverridesarrayA list of input parameters whose values you want to update for the specified 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 update 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. If you add a parameter to a template, before you can override the parameter value specified in the StackSet you must first use UpdateStackSet to update all stack instances with the updated template and parameter value specified in the StackSet. Once a stack instance has been updated with the new parameter, you can then override the parameter value using UpdateStackInstances.
RegionsarrayThe Amazon Web Services Regions where you want to delete StackSet instances.
StackInstanceAccountstringThe name of the Amazon Web Services account that you want to list stack instances for.
StackInstanceRegionstringThe name of the Region where you want to list stack instances.

SELECT examples

Returns the stack instance that's associated with the specified StackSet, Amazon Web Services account, and Amazon Web Services Region. For a list of stack instances that are associated with a specific StackSet, use ListStackInstances.

SELECT
account,
drift_status,
last_drift_check_timestamp,
last_operation_id,
organizational_unit_id,
parameter_overrides,
region,
stack_id,
stack_instance_status,
stack_set_id,
status,
status_reason
FROM aws.cloudformation.stack_instances
WHERE StackSetName = '{{ StackSetName }}' -- required
AND StackInstanceAccount = '{{ StackInstanceAccount }}' -- required
AND StackInstanceRegion = '{{ StackInstanceRegion }}' -- required
AND region = '{{ region }}' -- required
AND CallAs = '{{ CallAs }}'
;

INSERT examples

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.

INSERT INTO aws.cloudformation.stack_instances (
StackSetName,
region,
Accounts,
DeploymentTargets,
Regions,
ParameterOverrides,
OperationPreferences,
OperationId,
CallAs
)
SELECT
'{{ StackSetName }}',
'{{ region }}',
'{{ Accounts }}',
'{{ DeploymentTargets }}',
'{{ Regions }}',
'{{ ParameterOverrides }}',
'{{ OperationPreferences }}',
'{{ OperationId }}',
'{{ CallAs }}'
RETURNING
line_items
;

UPDATE examples

Updates the parameter values for 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 can only update stack instances in Amazon Web Services Regions and accounts where they already exist; to create additional stack instances, use CreateStackInstances. During StackSet updates, any parameters overridden for a stack instance aren't updated, but retain their overridden value. You can only update the parameter values that are specified in the StackSet. To add or delete a parameter itself, use UpdateStackSet to update the StackSet template. If you add a parameter to a template, before you can override the parameter value specified in the StackSet you must first use UpdateStackSet to update all stack instances with the updated template and parameter value specified in the StackSet. Once a stack instance has been updated with the new parameter, you can then override the parameter value using UpdateStackInstances. The maximum number of organizational unit (OUs) supported by a UpdateStackInstances 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.

UPDATE aws.cloudformation.stack_instances
SET
-- No updatable properties
WHERE
StackSetName = '{{ StackSetName }}' --required
AND region = '{{ region }}' --required
AND Accounts = '{{ Accounts}}'
AND DeploymentTargets = '{{ DeploymentTargets}}'
AND Regions = '{{ Regions}}'
AND ParameterOverrides = '{{ ParameterOverrides}}'
AND OperationPreferences = '{{ OperationPreferences}}'
AND OperationId = '{{ OperationId}}'
AND CallAs = '{{ CallAs}}'
RETURNING
line_items;

DELETE examples

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.

DELETE FROM aws.cloudformation.stack_instances
WHERE StackSetName = '{{ StackSetName }}' --required
AND RetainStacks = '{{ RetainStacks }}' --required
AND region = '{{ region }}' --required
AND Accounts = '{{ Accounts }}'
AND DeploymentTargets = '{{ DeploymentTargets }}'
AND Regions = '{{ Regions }}'
AND OperationPreferences = '{{ OperationPreferences }}'
AND OperationId = '{{ OperationId }}'
AND CallAs = '{{ CallAs }}'
;