How do I resolve the CloudFormation stack set errors "no stack instance found" or "Organizational unit not found in StackSet"?

3 minute read
0

I want to troubleshoot the stack set error I get when I try to update and deploy my stack set parameters or template.

Short description

These errors occurs in self-managed or service-managed stack sets when you add a new account or Organizational unit (OU).

Self-managed permissions

Error: Stack Instances not found, region: us-east-1, accounts: [123456789012]

The above error occurs when you use the Edit StackSet details option to update the stack set. The error message appears during an update operation for these reasons:

  • You added a new account to a stack set that doesn't have a stack instance
  • You added a new OU to a stack set but the new OU isn't a target of this stack set

As the stack set can't find the stack instance for the newly added deployment target to deploy changes, deployment fails.

Service-managed permissions

Error: Organizational unit ou-9gyj not found in stack set

You might try to deploy a stack set towards a new OU that's outside the stack set. This causes the stack set to deploy new stack instances to those accounts that aren't targeted within the stack set.

If these update operations are performed through Edit StackSet details the stack set validations fails.
Note: The error is usually observed when you select an untargeted OU. Even if automatic deployment is active, it's triggered only when accounts are added, removed, or moved between the targeted OUs.

Resolution

Use the Add stacks to StackSet option to add new accounts or OUs for stack sets that use self-managed or service-managed permissions.

You can use this option with either the AWS CloudFormation console or the AWS Command Line Interface (AWS CLI) commands.
Note: If you receive errors when you run AWS CLI commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.

Use the CloudFormation console

  1. Open the AWS CloudFormation console.
  2. Add stack instances to a stack set.

AWS CloudFormation starts creating your stack instances. View the progress and status of the stack instances in your stack set in the StackSet details page that opens when you choose Submit. When complete, your new stack instances are listed on the Stack instances tab.

Use AWS CLI

In the AWS CLI, run the following command:

aws cloudformation create-stack-instances \ —stack-set-name YOUR_STACK_SET_NAME \ —accounts YOUR_ACCOUNT_ID_1 YOUR_ACCOUNT_ID_2 \ —regions REGION_1 REGION_2

For a service-managed account, enter the following AWS CLI command:

aws cloudformation create-stack-instances --stack-set-name STACK_SET_NAME --accounts ACCOUNT_IDS --regions REGIONS --deployment-targets OrganizationalUnitIds=ORGANIZATIONAL_UNIT_IDS

Note: Replace YOUR_STACK_SET_NAME with the name of your stack set. Replace your YOUR_ACCOUNT_ID_1 and YOUR_ACCOUNT_ID_2 with the AWS account IDs where you want to add the stack instances. Replace REGION_1 and REGION_2 with the AWS Regions where you want to deploy the stack instances. Replace ORGANIZATIONAL_UNIT_IDS with the OU IDs of the AWS Organizations where you want to add the stack instances.

When complete, the new instances are added as deployment targets for your stack set. You can now use the Edit StackSet details option to update the stack set.

Related information

Permission models for stack sets

create-stack-instances

AWS OFFICIAL
AWS OFFICIALUpdated 2 months ago