A tool to render SAM templates locally with SAM config overrides
Project description
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. - SAM Config Support: Parses
samconfig.tomlto apply environment-specificparameter_overridesautomatically. - 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
Fn::ImportValuedata from AWS 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 examples/template.yaml --config examples/samconfig.toml --env dev
Fetching Real Exports
By default, Fn::ImportValue returns a mock string. Provide an AWS profile to fetch real values from CloudFormation exports.
uv run sam-render template.yaml --config samconfig.toml --env dev --profile my-aws-profile
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). |
Development & Testing
Tests are written using pytest.
# Run all tests
uv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file samrenderer-0.1.0.tar.gz.
File metadata
- Download URL: samrenderer-0.1.0.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd36870423c454da059e918e745630c3cca968d9fd89f4cc5b1ee4fc4576cd2a
|
|
| MD5 |
d129ac96008b5cdedbbcc311c6a630c0
|
|
| BLAKE2b-256 |
98452288504574b6791da1419ffffde17713552f8fdecaf9d2de7500650a20cb
|
Provenance
The following attestation bundles were made for samrenderer-0.1.0.tar.gz:
Publisher:
ci.yml on ryanm101/samrenderer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
samrenderer-0.1.0.tar.gz -
Subject digest:
fd36870423c454da059e918e745630c3cca968d9fd89f4cc5b1ee4fc4576cd2a - Sigstore transparency entry: 708821162
- Sigstore integration time:
-
Permalink:
ryanm101/samrenderer@38d5091bf51e471af4fb79754796abf41c37d43e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ryanm101
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@38d5091bf51e471af4fb79754796abf41c37d43e -
Trigger Event:
push
-
Statement type:
File details
Details for the file samrenderer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: samrenderer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
107e41ad01b67bf3a9de02d5d43e7b0ea2a288ea2a54ba9b501ee12bfe5e06bb
|
|
| MD5 |
2991b5fd62d1e7e4585f98d4b37cc4c5
|
|
| BLAKE2b-256 |
24f195388ddd9f2e84369e0d3d15c07f5bd198930c559fc30d1986f89d20c945
|
Provenance
The following attestation bundles were made for samrenderer-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on ryanm101/samrenderer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
samrenderer-0.1.0-py3-none-any.whl -
Subject digest:
107e41ad01b67bf3a9de02d5d43e7b0ea2a288ea2a54ba9b501ee12bfe5e06bb - Sigstore transparency entry: 708821167
- Sigstore integration time:
-
Permalink:
ryanm101/samrenderer@38d5091bf51e471af4fb79754796abf41c37d43e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ryanm101
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@38d5091bf51e471af4fb79754796abf41c37d43e -
Trigger Event:
push
-
Statement type: