Overview
Templates live in the templates/ directory. Rain deploys each file as a separate CloudFormation stack, matching it with environment-specific parameters from parameters/<env>/.
Location and format
Store every template under templates/. Both YAML (.yml or .yaml) and JSON formats are 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
| Convention | Description |
|---|---|
| File naming | Use lowercase, hyphen-separated names (e.g., network.yml, oidc-provider.yml) |
| Stack names | Override with StackName in parameter files for multi-environment usage |
| Parameter pairing | Match template and parameter file names exactly; deploy script auto-discovers configuration |
Rain deployment behavior
During deployment, the script executes:
rain deploy "<template>" --yes --config "<parameters>"
| Flag | Purpose |
|---|---|
--yes | Skips interactive prompts so CI/CD stays non-blocking |
--config | Loads parameters and tags from the environment folder |
If no matching parameter file exists, Rain deploys the template with defaults.
To experiment with change sets or additional flags, run Rain directly or modify the deploy script.
For a step-by-step walkthrough, read our guide on deploying a CloudFormation template.
Adding templates
Add new files to ./templates and commit to the main branch. The CI/CD workflow automatically deploys new stacks using the provided parameter files.
Template resources:
- Official AWS CloudFormation Templates
- Widdix's AWS CloudFormation Templates
- AWS Quick Start Templates
Best practices
| Practice | Description |
|---|---|
| Use Transform section | Leverage Transform for macro libraries like AWS SAM |
| Add Metadata blocks | Document why resources exist and which team owns them |
| Keep idempotent | Avoid Custom:: resources with destructive operations unless they handle retries cleanly |
| Use consistent tagging | Apply tags via parameter files for cost allocation and organization |
Next steps
- Parameters reference - Configuration file structure
- Rain reference - Deployment CLI details
- Scripts reference - Helper automation