Pulumi AWSX

3.5.0 · active · verified Thu Apr 16

Pulumi Amazon Web Services (AWS) AWSX Components is a collection of higher-level Pulumi components that simplify common AWS infrastructure patterns, such as VPCs, ECS clusters, and EC2 instances. It abstracts away much of the complexity of the underlying `pulumi-aws` provider. The current version is 3.5.0, and it follows a frequent release cadence, often aligning with updates to the core `pulumi-aws` provider.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a complete AWS Virtual Private Cloud (VPC) with public and private subnets across multiple availability zones using the `pulumi-awsx.ec2.Vpc` component. This component handles the creation of all necessary networking resources like internet gateways, NAT gateways, route tables, and subnet associations automatically. To run, ensure AWS credentials and region are configured for your Pulumi project.

import pulumi
import pulumi_awsx as awsx
import os

# Pulumi requires AWS credentials and a region to be configured.
# This can be done via environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
# or Pulumi configuration (pulumi config set aws:region us-east-1).
# For demonstration, ensure credentials are set up in your environment.
aws_region = os.environ.get('AWS_REGION', 'us-east-1') # Default to us-east-1 if not set

# Create an AWS VPC using pulumi-awsx.ec2.Vpc component.
# This component simplifies creating a VPC with public, private, and isolated subnets
# across multiple availability zones automatically.
my_vpc = awsx.ec2.Vpc("my-awsx-vpc",
                   cidr_block="10.0.0.0/16",
                   number_of_availability_zones=2, # Specify number of AZs
                   tags={
                       "Project": "PulumiAWSXQuickstart",
                       "ManagedBy": "Pulumi"
                   })

# Export the VPC ID and the IDs of its public and private subnets.
pulumi.export("vpc_id", my_vpc.vpc_id)
pulumi.export("public_subnet_ids", my_vpc.public_subnet_ids)
pulumi.export("private_subnet_ids", my_vpc.private_subnet_ids)

view raw JSON →