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
| Convention | Description |
|---|---|
| File naming | Use lowercase, hyphen-separated file names (e.g., network.yml, oidc-provider.yml) |
| Stack names | Keep predictable by including StackName override in template for multi-environment usage |
| Parameter pairing | Pair every template with parameter files sharing the same base name; deploy script auto-discovers configuration |
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
| Practice | Description |
|---|---|
| Use Transform section | Leverage Transform for macro libraries like AWS SAM for higher-level abstractions |
| 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 |
Need pointers on parameter files? Continue to the Parameters reference.