Location and format
Store every template under templates/. YAML (.yml or .yaml) and JSON are both supported. Rain deploys each file individually, so keep tightly related resources together in one template to minimize the number of stacks you manage.
Naming conventions
- Use lowercase, hyphen-separated file names (for example network.yml,oidc-provider.yml).
- Keep the stack name predictable by including a StackNameoverride inside the template if you have multiple environments consuming the same file.
- Pair every template with parameter files that share the same base name. The deploy script relies on that pattern to find configuration automatically.
Rain behavior
During deployment, the script executes:
rain deploy "<template>" --yes --config "<parameters>"
- --yesskips interactive prompts so CI/CD stays non-blocking.
- --configloads parameters and tags from the environment folder. If no matching file exists, Rain deploys the template with defaults.
- To experiment with change sets or additional flags, run Rain directly from your shell or modify the deploy script to include the options you want.
For a refresher on the manual workflow, read our step-by-step guide on deploying a CloudFormation template.
Start adding CloudFormation templates
To start adding CloudFormation templates, simply add new files to the ./templates directory and commit them to the main branch of your repository to trigger the CI/CD workflow. The workflow will automatically deploy your stacks using the provided parameter files.
Here are a couple of repositories containing CloudFormation templates that you can use as a starting point:
- Official AWS CloudFormation Templates
- Widdix's AWS CloudFormation Templates
- AWS Quick Start Templates
Recommended practices
- Use the Transform section for common macro libraries such as AWS SAM if you want higher-level abstractions.
- Add descriptive Metadatablocks to document why a resource exists or which team owns it.
- Keep templates idempotent; avoid Custom::resources that perform destructive operations unless they handle retries cleanly.
Need pointers on parameter files? Continue to the Parameters reference.