SAM Template Renderer
A lightweight Python tool to parse, resolve, and render AWS SAM and CloudFormation templates locally.
This tool is designed to help debug complex template logic—specifically Mappings, Conditions, and Substitutions—without needing to deploy to AWS. It resolves intrinsic functions locally and outputs the final "rendered" YAML.
Features
- Intrinsic Function Resolution: Evaluates
Fn::FindInMap,Fn::If,Fn::Sub,Fn::Join,Fn::Select,Fn::Split, and more locally. - Logic Handling: Fully supports boolean logic (
Fn::And,Fn::Or,Fn::Not,Fn::Equals) to correctly evaluate Condition blocks. - Environment Diffing: Compare the rendered output of two different environments (e.g., dev vs prod) to visualize configuration differences.
- Dynamic References: Resolves
{{resolve:secretsmanager:...}}patterns when an AWS profile is active. - SAM Config Support: Parses
samconfig.tomlto apply environment-specific parameter_overrides automatically. - Custom YAML Tags: Handles short-form CloudFormation tags (e.g.,
!Ref,!Sub,!GetAtt) without parsing errors. - Hybrid Resolution: Mocks runtime values (like Resource IDs) but can optionally fetch real values from AWS (Imports, Secrets) if a profile is provided.
- Extended Syntax: Supports custom 4th-argument "DefaultValue" syntax for
Fn::FindInMap.
Installation
This project is managed with uv.
# Clone the repository
git clone git@github.com:ryanm101/samrenderer.git
cd samrenderer
# Install dependencies and sync environment
uv sync
Usage
Run the renderer against a template file. You can optionally specify a samconfig.toml environment or an AWS profile.
Basic Rendering
Resolves parameters using defaults defined in the template.
uv run sam-render template.yaml
Using SAM Config (Recommended)
Applies parameters from [<env>.deploy.parameters] in samconfig.toml.
uv run sam-render template.yaml --config samconfig.toml --env dev
Comparing Environments
Generate a colored diff between two environments defined in samconfig.toml. This is useful for detecting drift or verifying configuration changes between stages.
uv run sam-render template.yaml --config samconfig.toml --env dev --env2 stag
AWS Integration (Imports & Secrets)
By default, Fn::ImportValue and {{resolve:secretsmanager:...}} return mock strings. Provide an AWS profile to fetch real values from your AWS account.
# Single Env, single acccout
uv run sam-render template.yaml --config samconfig.toml --env dev --profile my-aws-profile
# Compare Envs in a single account
uv run sam-render template.yaml --config samconfig.toml --env dev --env2 dev1 --profile my-aws-profile
# Compare Envs in different accounts
uv run sam-render template.yaml --config samconfig.toml --env dev --env2 dev1 --profile my-aws-profile --profile2 my-aws-profile2
Supported Functions
| Category | Function | Status | Notes |
|---|---|---|---|
| Core | Ref | ✅ | Resolves Parameters/Pseudo-params; mocks Resources. |
| Fn::GetAtt | ⚠️ | Returns mock string mock-resource-attr. | |
| Fn::ImportValue | ✅ | Fetches from AWS if --profile is set, otherwise mocks. |
|
| Logic | Fn::If | ✅ | Full support. |
| Fn::Equals | ✅ | Full support. | |
| Fn::Not | ✅ | Full support. | |
| Fn::And / Or | ✅ | Full support. | |
| Condition | ✅ | Resolves Condition keys in dictionaries. | |
| Maps | Fn::FindInMap | ✅ | Supports standard 3-arg and custom 4-arg (DefaultValue) syntax. |
| String | Fn::Sub | ✅ | Supports String and Key-Value map interpolation. |
| Fn::Join | ✅ | Full support. | |
| Fn::Split | ✅ | Full support. | |
| Fn::Select | ✅ | Full support. | |
| Fn::Base64 | ⚠️ | Returns readable string [Base64: ...] instead of encoding. |
|
| Fn::GetAZs | ⚠️ | Returns mock list based on Region (e.g., us-east-1a, 1b, 1c). | |
| Dynamic | {{resolve:...}} | ✅ | Supports Secrets Manager lookups (JSON & String) with --profile. |
Development & Testing
Makefile is used to provide consistency between local and remote builds.
make help
Tests are written using pytest.
make test
Metadata
Release files for samrenderer 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| samrenderer-0.2.0.tar.gz | 39.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| samrenderer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.2 kB
Release files / samrenderer-0.2.0.tar.gz
| Download URL | samrenderer-0.2.0.tar.gz |
|---|---|
| Size | 39.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07bc9373ff3be3b7eb1839d36e764cb29d45aca7a481c5301141ff6b3e052706
|
|
BLAKE2b-256 checksum How to use checksums |
f02c871ee8ed16e086af06cfce8da63c914a1145643c1ca54c87f532cfcde0e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2025.
Transparency logRelease files / samrenderer-0.2.0-py3-none-any.whl
| Download URL | samrenderer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83afcfb708a68b34249ec6ca4bb4e6defb3bc58f639498b728122adc7317398a
|
|
BLAKE2b-256 checksum How to use checksums |
91acc878b757c062498972835b6124630683c297c418115e43a2d7c8a3683758
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2025.
Transparency log