pulumi-basics
12
总安装量
12
周安装量
#26202
全站排名
安装命令
npx skills add https://github.com/thebushidocollective/han --skill pulumi-basics
Agent 安装分布
codex
11
claude-code
10
opencode
10
gemini-cli
9
antigravity
9
windsurf
9
Skill 文档
Pulumi Basics
Infrastructure-as-code using real programming languages with Pulumi.
Project Structure
my-infrastructure/
âââ Pulumi.yaml # Project file
âââ Pulumi.dev.yaml # Stack config
âââ index.ts # Main program
âââ package.json
Pulumi.yaml
name: my-infrastructure
user-invocable: false
runtime: nodejs
description: My infrastructure project
TypeScript Example
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Create VPC
const vpc = new aws.ec2.Vpc("main", {
cidrBlock: "10.0.0.0/16",
enableDnsHostnames: true,
tags: {
Name: "main-vpc",
},
});
// Create subnet
const subnet = new aws.ec2.Subnet("public", {
vpcId: vpc.id,
cidrBlock: "10.0.1.0/24",
availabilityZone: "us-east-1a",
});
// Export outputs
export const vpcId = vpc.id;
export const subnetId = subnet.id;
Common Commands
# Create new project
pulumi new aws-typescript
# Preview changes
pulumi preview
# Apply changes
pulumi up
# Destroy resources
pulumi destroy
# View stack outputs
pulumi stack output
Configuration
# Set config
pulumi config set aws:region us-east-1
# Set secret
pulumi config set --secret dbPassword mySecret123
# Get config
pulumi config get aws:region
Best Practices
Use Stack References
const infraStack = new pulumi.StackReference("org/infra/prod");
const vpcId = infraStack.getOutput("vpcId");
Component Resources
class MyApp extends pulumi.ComponentResource {
constructor(name: string, args: MyAppArgs, opts?: pulumi.ComponentResourceOptions) {
super("custom:app:MyApp", name, {}, opts);
// Create resources
}
}