Pulumi AWS
Pulumi AWS is a Python package that enables users to define, deploy, and manage Amazon Web Services (AWS) cloud resources using Python code. It is the most widely used provider in the Pulumi ecosystem and offers access to the full surface area of the upstream Terraform AWS Provider. The library is actively maintained with frequent minor and patch releases, typically tied to updates in the underlying Terraform AWS Provider, with major versions released periodically to incorporate significant upstream changes and Pulumi-specific enhancements.
Warnings
- breaking The `assumeRole` property on the Pulumi AWS Provider resource has changed to `assumeRoles`, which now accepts a list of role objects. This enables IAM role chaining. If you were using `assumeRole` for provider configuration, you must update your code.
- breaking The S3 `Bucket` and `BucketV2` resources have been unified into a single `aws.s3.Bucket` resource. While existing `BucketV2` usages should be aliased, `aws.s3.Bucket` now reflects the latest upstream Terraform implementation. You may need to update resource definitions to simply use `aws.s3.Bucket`.
- gotcha When upgrading to Pulumi AWS v7, a special command is required to migrate the state file. Failure to do so can result in unexpected diffs or deployment errors.
- gotcha Pulumi AWS v7 introduces a `region` input property to most resources, allowing multi-region deployments with a single provider. While this reduces memory usage by not requiring multiple provider instances, users migrating from older versions that relied on explicit provider configurations per region might need to update their resource definitions to leverage this new capability or explicitly define provider instances for specific regions.
- gotcha Due to Pulumi's relative novelty compared to tools like Terraform, online search results and AI-generated code for `pulumi-aws` (especially in Python) can sometimes be outdated or contain 'hallucinated' (incorrect) patterns. Always cross-reference with the official Pulumi documentation for accuracy.
Install
-
pip install pulumi_aws pulumi
Imports
- pulumi
import pulumi
- aws
import pulumi_aws as aws
- Bucket
aws.s3.Bucket
- Role
aws.iam.Role
- Vpc
aws.ec2.Vpc
Quickstart
import pulumi
import pulumi_aws as aws
import os
# Configure the AWS region using Pulumi config or environment variables.
# For example: pulumi config set aws:region us-east-1
# Or set AWS_REGION environment variable.
# Create an AWS S3 bucket. Pulumi automatically suffixes the name for global uniqueness.
bucket = aws.s3.Bucket("my-unique-bucket",
tags={
"Environment": os.environ.get('PULUMI_ENVIRONMENT', 'development'),
"Project": "MyPulumiApp"
}
)
# Export the name and website endpoint of the bucket
pulumi.export('bucket_name', bucket.id)
pulumi.export('bucket_arn', bucket.arn)