I'm running into some issues with my aws cloud formation template.
I have a general staging.yaml file where I define all my lambdas and apis. Problem is, that file has gotten WAY too big. So I decided to use this package: https://www.npmjs.com/package/cfn-include. So I can break the file up into several templates. As such:
Fn::Merge:
- !Include ./templates/api-lambdas/accounts.yaml
- !Include ./templates/api-lambdas/officers.yaml
- !Include ./templates/api-lambdas/branches.yaml
My question is, is there any way of passing variables into these includes? I.E:
- !include ./templates/api-lambdas/accounts/yaml, variables: {database: databaseName, environment: staging}
And the accounts.yaml would look like this:
Environment:
Variables:
ENV: ${environment}
DB_NAME: ${databaseName}
Thanks!
There is one more alternative: cfpack.js tool. It allows you to split your gigantic template into smaller templates that will be combined into one and deployed to your CloudFormation stack.
Maybe you want to give nested stacks a try (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html) Usually when files got too big to be readable, they might reach the max template size restriction soon after. There you can pass all the parameters you have in your root file to the substacks pretty easy and in a typed manner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With