troposphere
AWS CloudFormation creation library
What it is and what it does
Troposphere lets you write AWS CloudFormation templates as Python code instead of JSON or YAML. You define AWS resources using Python classes, set their properties, and the library generates valid CloudFormation JSON or YAML output. The library validates resource properties and types as you build the template, catching configuration errors before deployment rather than during stack creation.
It's designed for teams that prefer programmatic infrastructure definition and want type safety and early error detection. The library includes support for AWS resources and basic OpenStack Heat resources. A single optional dependency (cfn_flip) handles output format conversion.
Use it for:
- Generate CloudFormation templates programmatically for repeatable infrastructure deployments across environments
- Catch CloudFormation configuration errors at development time through property and type validation
- Build infrastructure templates using Python control flow, functions, and version control-friendly code
- Convert between CloudFormation JSON and YAML formats during template generation and deployment
- Define reusable infrastructure components as Python classes and functions for consistent resource patterns
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Troposphere is a Python library that generates AWS CloudFormation templates by writing Python code instead of hand-crafting JSON or YAML, with built-in property and type validation to catch errors early.
Yes. Troposphere is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real problem for teams managing AWS infrastructure as code. The permissive license and broad Python version support (3.8+) make it low-risk to adopt. Install it if you prefer writing infrastructure in Python over hand-editing CloudFormation templates.
Install
troposphere on PyPI
pip
pip install troposphereuv
uv add tropospherepoetry
poetry add troposphereInstalling troposphere
Before you install
Low friction installation as a pure Python wheel with a single runtime dependency (cfn_flip). The package is actively maintained with a recent release and has been stable since its early releases.
License in practice
BSD-2-Clause is a permissive license that allows commercial use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
pip install troposphere
from troposphere import Template, Ref
import troposphere.ec2 as ec2
t = Template()
instance = ec2.Instance("myinstance", ImageId="ami-951945d0", InstanceType="t1.micro")
t.add_resource(instance)
print(t.to_json())
Verify before relying
- Whether cfn_flip is required at runtime or only for optional output format conversion
- Scope and completeness of AWS resource type coverage relative to current CloudFormation service offerings
Package facts
| License | BSD-2-Clause (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — cfn_flip |
| Maintenance | actively maintained — 90 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,281,350/month — #4,116 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: troposphere-4.10.2-py3-none-any.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
aws-sam-translatorTransforms AWS Serverless Application Model…
permissive · top 1,000 on PyPI
aws-cdk.aws-cloudformationDefines AWS CloudFormation resources…
permissive · top 15,000 on PyPI
awacsawacs generates AWS IAM policy JSON from Python…
permissive · top 15,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
aws-cdk.coreProvides the core construct classes and stack…
permissive · top 15,000 on PyPI
python-heatclientPython client library and command-line tool for…
permissive · top 15,000 on PyPI
aws-cdk.aws-ecsProvides AWS CDK constructs for defining and…
permissive · top 15,000 on PyPI
aws-cdk.aws-ec2Provides AWS CDK constructs for defining EC2…
permissive · top 15,000 on PyPI
cfn-flipConverts AWS CloudFormation templates between…
permissive · top 5,000 on PyPI
aws-cdk-libProvides Python APIs to define and deploy AWS…
permissive · top 5,000 on PyPI