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

Create a "How-To Define a Nested Stack" section #358

Closed
Doug-AWS opened this issue Jul 17, 2018 · 11 comments
Closed

Create a "How-To Define a Nested Stack" section #358

Doug-AWS opened this issue Jul 17, 2018 · 11 comments
Assignees
Labels
docs/guide Related to the developer guide guidance Question that needs advice or information.

Comments

@Doug-AWS
Copy link
Contributor

No description provided.

@hassankhan
Copy link

It seems the only way to define a nested stack right now is in the examples. Is there any way of using the Stack classes directly to achieve the same result?

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 20, 2018

@hassankhan, not right now but we have an open design ticket that will ultimately address this use case: #233

As an aside, can you describe a bit about your use case where you're using CDK but still want to use nested stacks? In particular, can you elaborate on why writing your shared code as a construct and deploying it "inline" in the same stack is not sufficient?

@hassankhan
Copy link

Hi @rix0rrr, thanks for the reply. Our main use-case for nested stacks is something similar to the following:

  • Base Stack (sets up Hosted Zone, ACM certificate)
  • Resource Stack (DynamoDB tables, AutoScaling plans for the tables)
  • API stack (Lambda + API Gateway)

Since each of these stacks has a hard dependency on the previous one, we need to ensure that they are deployed in the correct order. As far as I understand, this can be achieved in a "parent" CloudFormation stack by using the DependsOn clause.

As for why we would prefer not to use a single stack - we've often found ourselves running afoul of the much-dreaded 200 Resource limit. This comes up a lot with Lambda+APIG stacks and, as far as I know, has no easy solution aside from either nested stacks or using a single Lambda for the API.

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 20, 2018

Okay, so it boils down to the 200 resource limit, correct? You're not trying to achieve reuse between the stacks, but you are splitting up the resources (and then deploying them in order) in order to get around this limitation.

Let me ask you something, as a potential future customer of a feature I've been mulling over: in my ideal future world, you would never worry or see stacks directly (unless you wanted to); you would simply add more and more resources into your CDK application, and if you approach the 200 resources limit, the system would automatically start splitting your resources over multiple stacks.

Would that sound good to you, or would you prefer keeping control over slicing the resources over stacks?

@hassankhan
Copy link

You're not trying to achieve reuse between the stacks

Somewhat - we deploy the same set of three stacks in each client account so there is some re-use in that sense. However, the accounts are siloed off (so largely they are unaware of each other).

in my ideal future world, you would never worry or see stacks directly

This sounds really really cool! We currently make heavy use of the Serverless Framework right now, and stack splitting has been a hot topic of discussion there, too. IIRC, it wasn't ever implemented because different people have different ideas on how the stack should be split. My only concern with auto-splitting is it somewhat breaks the "logical" separation when defining them explicitly - that said, if all you want is a "stack" that supports more than 200 resources then this could definitely work 👍

I wonder if the CDK could support both use cases; there could be a SmartStack construct that intelligently splits resources into however many stacks, and a NestedStack construct that only has children of type Stack.

@tvb
Copy link

tvb commented Oct 9, 2018

Adding to this discussion. I think the cdk can only be really useful if the 200 resource limit for CFN templates can be dealt with.

@Doug-AWS
Copy link
Contributor Author

Doug-AWS commented Oct 9, 2018

Depends upon resolving issue #233

@tvb
Copy link

tvb commented Oct 9, 2018

@Doug-AWS thanks for replying. I'll be monitoring #233 closely then.

@srchase srchase added guidance Question that needs advice or information. and removed how-to labels Jan 3, 2019
@Doug-AWS
Copy link
Contributor Author

233 is still open

@Doug-AWS Doug-AWS added the docs/guide Related to the developer guide label Jan 23, 2019
@Doug-AWS
Copy link
Contributor Author

Dropping the priority and adding to the backlog.

@Doug-AWS Doug-AWS added p2 backlog and removed p1 labels Jan 29, 2019
@Doug-AWS Doug-AWS self-assigned this Feb 26, 2019
@Doug-AWS Doug-AWS changed the title Create a "How-To Define a Nested Stack" section in the docs Create a "How-To Define a Nested Stack" section Feb 27, 2019
@Doug-AWS Doug-AWS removed the p2 label Apr 16, 2019
@Doug-AWS
Copy link
Contributor Author

Moving guide issues to doc repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs/guide Related to the developer guide guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

5 participants