A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
The Pulumi AWS provider enables infrastructure-as-code management for Amazon Web Services using TypeScript, JavaScript, Python, Go, .NET, and Java.
npm install @pulumi/awsNew to Pulumi AWS? → Quick Start Guide (5 min)
Basic imports:
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";First resource:
const bucket = new aws.s3.BucketV2("my-bucket");
export const bucketName = bucket.id;Run code and manage servers → Compute Overview
Object, block, and file storage → Storage Overview
Relational, NoSQL, caching, and data warehousing → Database Overview
VPCs, DNS, CDN, load balancing, API management → Networking Overview
Identity, encryption, secrets, certificates, threat detection → Security Overview
Messaging, queuing, notifications, workflows → Services Overview
Logging, monitoring, auditing, configuration → Services Overview
Analytics, ML, DevOps, migration, cost management → Services Overview
Resources are infrastructure components you create and manage.
class Resource extends pulumi.CustomResource {
constructor(name: string, args: ResourceArgs, opts?: pulumi.CustomResourceOptions);
}Example:
const vpc = new aws.ec2.Vpc("my-vpc", {
cidrBlock: "10.0.0.0/16",
tags: { Name: "my-vpc" },
});Data sources query existing AWS resources.
function getResource(args: GetResourceArgs): Promise<GetResourceResult>;Example:
const defaultVpc = await aws.ec2.getVpc({ default: true });Outputs represent resource properties that may not be known until after deployment.
interface Output<T> {
apply<U>(func: (t: T) => Input<U>): Output<U>;
}Example:
export const bucketArn = bucket.arn; // Output<string>Pulumi automatically tracks dependencies between resources.
const vpc = new aws.ec2.Vpc("vpc", { cidrBlock: "10.0.0.0/16" });
const subnet = new aws.ec2.Subnet("subnet", {
vpcId: vpc.id, // Automatic dependency
cidrBlock: "10.0.1.0/24",
});The Provider configures AWS authentication and default settings.
class Provider extends pulumi.ProviderResource {
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions);
}
interface ProviderArgs {
region?: pulumi.Input<string>;
profile?: pulumi.Input<string>;
accessKey?: pulumi.Input<string>;
secretKey?: pulumi.Input<string>;
assumeRoles?: pulumi.Input<pulumi.Input<AssumeRole>[]>;
defaultTags?: pulumi.Input<DefaultTags>;
// ... additional configuration
}Example:
const provider = new aws.Provider("my-provider", {
region: "us-west-2",
defaultTags: { tags: { Environment: "production" } },
});
const bucket = new aws.s3.BucketV2("bucket", {}, { provider });const commonTags = {
Environment: "production",
Project: "my-app",
ManagedBy: "pulumi",
};
const bucket = new aws.s3.BucketV2("bucket", {
tags: commonTags,
});const bucket = new aws.s3.BucketV2("bucket");
// Apply transformations to outputs
const bucketDomain = bucket.bucket.apply(name => `${name}.s3.amazonaws.com`);
// Use outputs as inputs to other resources
const policy = new aws.s3.BucketPolicy("policy", {
bucket: bucket.id, // Output<string> used as Input<string>
policy: bucket.arn.apply(arn => JSON.stringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: "*",
Action: "s3:GetObject",
Resource: `${arn}/*`,
}],
})),
});// Export from one stack
export const vpcId = vpc.id;
export const subnetIds = subnets.map(s => s.id);
// Import in another stack
const stackRef = new pulumi.StackReference("my-org/network-stack/prod");
const vpcId = stackRef.getOutput("vpcId");
const subnetIds = stackRef.getOutput("subnetIds");const usWest = new aws.Provider("us-west", { region: "us-west-2" });
const usEast = new aws.Provider("us-east", { region: "us-east-1" });
const westBucket = new aws.s3.BucketV2("west-bucket", {}, { provider: usWest });
const eastBucket = new aws.s3.BucketV2("east-bucket", {}, { provider: usEast });Accept literals, promises, or outputs:
type Input<T> = T | Promise<T> | Output<T>;// Tags
interface Tags {
[key: string]: pulumi.Input<string>;
}
// ARN
type ARN = string;
// Policy Documents
interface PolicyDocument {
Version?: string;
Statement: PolicyStatement[];
}
interface PolicyStatement {
Effect: "Allow" | "Deny";
Action?: string | string[];
Resource?: string | string[];
Principal?: PolicyPrincipal;
Condition?: { [operator: string]: { [key: string]: string | string[] } };
}Authentication Errors
Resource Conflicts
Dependency Errors
dependsOn option for non-automatic dependenciesThis documentation covers @pulumi/aws version 7.16.0. For version-specific changes, see the official changelog.
Install with Tessl CLI
npx tessl i tessl/npm-pulumi--aws