aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Support for building nested stacks with SAM resources

Open kgeisink opened this issue 7 years ago • 14 comments

Describe your idea/feature/enhancement

I would like for it to be possible to deploy a CloudFormation template which contains SAM resources and a nested stack which template in turn also contains SAM resources, without having to update the TemplateURL property of the nested stack in a separate, custom step.

Currently, when both the parent stack and nested stack contain SAM resources, they have to be built separately. This means that the TemplateURL property that refers to the nested stack's template is going to be wrong, not pointing to the template prepared by sam build. It would be great if this relation is kept during the build step, so packaging will still work as normal.

Proposal

(I don't know enough details about SAM CLI to know how realistic any proposal that I have is.)

  • Add a parameter to the build command that allows you to list your nested templates.
  • Somehow find the TemplateURL of any AWS::CloudFormation::Stack resource in a template and verify whether it contains SAM resources.

Additional Details

  • In issue #936 it was mentioned that nested templates are not yet supported in any SAM CLI commands and that it needed a general issue.
  • Putting the nested stack into SAR can work for some of the solutions out there, but not all resource types are supported by SAR so this can still be a problem.

kgeisink avatar Jun 06 '19 09:06 kgeisink

I too would like to see this feature. Currently as a workaround you can run "sam build" on all the nested SAM projects and then build/package/deploy from the parent SAM. A recursive SAM build could be added to projects using nested SAM applications.

ghost avatar Oct 16 '19 20:10 ghost

+1

trek10-k37z avatar Nov 29 '19 13:11 trek10-k37z

+1 for this feature

jeswanthamazon avatar Jan 20 '20 19:01 jeswanthamazon

+1 for this

netochaves avatar Feb 11 '20 21:02 netochaves

+1 for this

BeneyKim avatar Feb 12 '20 02:02 BeneyKim

I was encountering this problem even before moving to nested stack. What's wrong with sam build?

made2591-eb avatar Mar 05 '20 14:03 made2591-eb

+1

trek10-k37z avatar Mar 30 '20 11:03 trek10-k37z

+1

edreanernst avatar May 25 '20 15:05 edreanernst

+1

codergeorgej avatar May 29 '20 04:05 codergeorgej

I too would like to see this feature. Currently as a workaround you can run "sam build" on all the nested SAM projects and then build/package/deploy from the parent SAM. A recursive SAM build could be added to projects using nested SAM applications.

This is not feasible as the parent template would need to point to the generated yaml template in the .aws-sam directory to use the built packages. See #2061 Does anyone has another workaround for this?

I would love to see the sam build to work recursively as sam package does, please share updates or suggestions.

ronaldour avatar Jun 23 '20 23:06 ronaldour

Building resources in nested stack is enabled by default in #2662, to be released

aahung avatar Mar 03 '21 18:03 aahung

released in v1.20.0

aahung avatar Mar 04 '21 19:03 aahung

let us know if you encounter any issues with nested stacks!

aahung avatar Mar 04 '21 19:03 aahung

Looking forward to giving it a go very soon, thanks so much! :100:

milesgranger avatar Mar 04 '21 19:03 milesgranger