{"id":2819,"library":"troposphere","title":"Troposphere","description":"Troposphere is an open-source Python library that simplifies the creation of AWS CloudFormation JSON and YAML templates by allowing developers to define AWS resources using Python code. It offers a Pythonic syntax, built-in property and type checking to catch errors early, and promotes modular code. The library is actively maintained with frequent updates driven by the latest AWS Resource Specification, and also provides basic support for OpenStack Heat resources.","status":"active","version":"4.10.1","language":"en","source_language":"en","source_url":"https://github.com/cloudtools/troposphere","tags":["aws","cloudformation","iac","devops","infrastructure-as-code","python"],"install":[{"cmd":"pip install troposphere","lang":"bash","label":"Basic Installation"},{"cmd":"pip install troposphere[policy]","lang":"bash","label":"With IAM Policy Support (awacs)"}],"dependencies":[{"reason":"Required runtime environment.","package":"python","optional":false},{"reason":"Recommended for easier generation of IAM policies.","package":"awacs","optional":true}],"imports":[{"symbol":"Template","correct":"from troposphere import Template"},{"symbol":"ec2 (example service)","correct":"import troposphere.ec2 as ec2"},{"symbol":"Ref, GetAtt, Join","correct":"from troposphere import Ref, GetAtt, Join"}],"quickstart":{"code":"from troposphere import Template, Ref\nimport troposphere.ec2 as ec2\n\nt = Template()\nt.set_description(\"AWS CloudFormation template to create a single EC2 instance.\")\n\ninstance_name = \"MyWebServer\"\ninstance = t.add_resource(ec2.Instance(\n    instance_name,\n    ImageId=\"ami-0c55b159cbfafe1f0\", # Example AMI ID (Ubuntu 20.04 LTS HVM, SSD Volume Type)\n    InstanceType=\"t2.micro\",\n    KeyName=\"my-ssh-key\", # Replace with your EC2 Key Pair name\n    Tags=[\n        {\"Key\": \"Name\", \"Value\": instance_name}\n    ]\n))\n\n# Output the Public DNS name of the instance\nt.add_output(\n    [Ref(instance.get_att(\"PublicDnsName\"))],\n    \"Public DNS Name for the new EC2 instance\",\n    \"PublicDns\"\n)\n\nprint(t.to_json(indent=2))\n","lang":"python","description":"This quickstart code demonstrates how to create a basic AWS CloudFormation template using Troposphere to launch an EC2 instance. It defines an instance with a specific AMI, instance type, and key pair, and then outputs its public DNS name. Remember to replace `ami-0c55b159cbfafe1f0` and `my-ssh-key` with valid values for your AWS region and account. The template is then printed as a JSON string."},"warnings":[{"fix":"Review your existing templates that use affected `AWS::EC2` and `SpotFleet` properties and update them to use the new class structures or property types as per the 4.0.0 changelog.","message":"Version 4.0.0 introduced breaking changes due to a refactoring for auto-generation from the AWS Resource Specification. Specifically, properties for `AWS::EC2 - Ipv6Addresses` were changed from an `AWSHelperFn` class to an `AWSProperty`, and `SpotFleet::LaunchSpecifications` properties such as `IamInstanceProfile`, `NetworkInterfaces`, and `Placement` were updated to use dedicated specification classes (e.g., `IamInstanceProfileSpecification`).","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Stay informed about AWS CloudFormation updates and specification changes. Regularly validate your generated CloudFormation templates against the latest AWS service definitions.","message":"Troposphere closely mirrors AWS CloudFormation's underlying structure. This means that while Troposphere itself may not have a 'breaking change', fundamental changes or deprecations in the AWS CloudFormation service or resource specifications will directly impact how you construct your Troposphere templates. Users should regularly consult the AWS CloudFormation documentation alongside Troposphere's.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Monitor Troposphere's changelog for 'Updates from spec version X.Y.Z' entries and be prepared to make minor adjustments to your code if resource properties are renamed, removed, or have updated validation requirements.","message":"Troposphere classes are frequently updated to reflect the latest AWS Resource Specification versions. While this ensures support for new AWS features, it can lead to changes in property names, validation rules, or available attributes. For instance, `Transfer.WebApp.EndpointDetails` was renamed to `WebAppEndpointDetails` in 4.10.1.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you require custom resource generation or need to work with a very specific, unreleased version of the CloudFormation spec, consider cloning the Troposphere GitHub repository to access the `gen.py` script.","message":"The `gen.py` script, used to auto-generate Troposphere classes from the AWS Resource Specification, is typically only available by cloning the repository and not when installing `troposphere` via pip. This makes it difficult for users to generate custom or locally-updated resource classes without working directly from the source repository.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}