skillfed

troposphere

AWS CloudFormation creation library

troposphere v4.10.2 1.3M downloads/30d#4,116 on PyPI4,945
Permissive license BSD-2-Clause Active released

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 troposphere

uv

uv add troposphere

poetry

poetry add troposphere

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

cloudformation template generation pythonaws infrastructure as codecloudformation json builderpython cloudformation libraryinfrastructure automation awscloudformation type checkingaws resource definition python
infrastructure-as-codeaws-cloudformationtemplate-generation

More Build Tools packages