Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub-stacks on a StackSetStack don't get deployed by the StackSetStack #207

Open
mwareingWLL opened this issue Aug 21, 2023 · 1 comment
Open

Comments

@mwareingWLL
Copy link

Like the title says, if you specify a stack inside a StackSetStack, then the Stack doesn't get deployed. (or it can, using the --all flag but then it only gets deployed to the primary region as its own stack and not all target regions).

Here is an example of code that works for deploying a bucket to all regions:

const app = new App();
const stack = new Stack(app);

const stackSetStack = new StackSetStack(stack, "StackSetStack");
new Bucket(stackSetStack, "Bucket");

new StackSet(stack, 'StackSet', {
  target: StackSetTarget.fromAccounts({
    regions: ['eu-west-1', 'eu-west-2'],
    accounts: [process.env.CDK_DEFAULT_ACCOUNT!],
  }),
  template: StackSetTemplate.fromStackSetStack(stackSetStack),
});

As expected this deploys all the resources (a bucket in this case) to all the regions.

However, if you add a stack between the bucket and the StackSetStack, it no longer deploys the bucket to the all regions, e.g.

const app = new App();
const stack = new Stack(app);

const stackSetStack = new StackSetStack(stack, "StackSetStack");
const subStack = new Stack(stackSetStack, "SubStack");
new Bucket(subStack, "Bucket");

new StackSet(stack, 'StackSet', {
  target: StackSetTarget.fromAccounts({
    regions: ['eu-west-1', 'eu-west-2'],
    accounts: [process.env.CDK_DEFAULT_ACCOUNT!],
  }),
  template: StackSetTemplate.fromStackSetStack(stackSetStack),
});

My expected behaviour would be that this deploys the stack to all regions and all regions subsequently deploy a bucket.

Please correct me if I'm wrong.

@gshpychka
Copy link

This works the same way as with regular stacks - instantiating a Stack in the scope of a Stack doesn't result in a Nested stack - both are deployed in parallel. You need to use NestedStack explicitly instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants