0

Can I split the template.yml into multiple files? Its pretty cumbersome to navigate if theres lots of resources in there

user2741831
  • 2,120
  • 2
  • 22
  • 43
  • 1
    Did you consider maybe using [nested applications](https://aws.amazon.com/blogs/compute/announcing-nested-applications-for-aws-sam-and-the-aws-serverless-application-repository/)? I am assuming that this is a SAM template based on the tag on the question, but you might consider adding that into the title. – Brad Dec 26 '20 at 17:02
  • no its 1 microservice but its still a lot of resources – user2741831 Dec 26 '20 at 17:21
  • I'd probably "abuse" the nested application feature such that you test one part, add in some more, test that, add in some more... but I _think_ the general answer to your question is "no, you can't." Would be nice if it did, though! – Brad Dec 26 '20 at 17:24
  • I wonder If theres some Linux static linking named pipe trickery to stitch it together at the OS level. But that might be bad practice – user2741831 Dec 26 '20 at 21:04

1 Answers1

1

I haven't tried it yet, but planning to tomorrow with large SAM file that includes an embedded OpenAPI document.

Apparently there are tools that will stitch together YAML files using an include syntax. Granted you need to precompile but you could build that into a deploy script with yarn/npm.

yamlinc template.yml && sam deploy

or something like that.

  • unfortunately this doesn't seem to work on sam templates, yamlinc complains about custom tags: `Error on file 'template.yaml' unknown tag !<!Ref>` – Felipe Mar 16 '22 at 13:55
  • 1
    Right. That only really works with the OpenAPI doc since it conforms closer to the YAML spec. For anything CloudFormation related (including SAM) I use cfn-include now. https://www.npmjs.com/package/cfn-include – Jeremy Richardson Mar 17 '22 at 14:11