Pulumi Infrastructure as Code AI Skill Guide
Overview
Pulumi expresses cloud infrastructure as real programs (TypeScript, Python, Go, C#, YAML). State lives in a backend (Pulumi Cloud or self-managed); each stack is an isolated deployment of the same program (e.g. dev, prod). Agents should treat pulumi preview as mandatory before up, and treat stack secrets as first-class - plaintext config for credentials is a defect.
Program (index.ts / __main__.py)
|
v
+----------------+ preview/up +------------------+
| Stack config | ------------------> | Cloud providers |
| + secrets | <------------------ | AWS/GCP/Azure/k8s|
+----------------+ state refresh +------------------+
When to use
- Creating or reviewing Pulumi projects and stack configs
- Previewing diffs before applying infrastructure changes
- Managing stack secrets, provider credentials, and resource imports
- Migrating imperative cloud CLI scripts into durable IaC
Operational directives
- Always
pulumi stack select(or pass-s) before mutating; confirm withpulumi whoami -v. - Run
pulumi previewand summarize create/update/replace/delete counts beforepulumi up. - Store secrets with
pulumi config set --secret; never commit decrypted values. - Prefer immutable replaces carefully - call out replacements that destroy data (DBs, disks).
- Use resource options (
protect,retainOnDelete, aliases) for production stateful resources.
Concrete examples
Project bootstrap (TypeScript)
pulumi new aws-typescript -y -n api-infra -s dev
pulumi config set aws:region us-east-1
pulumi config set --secret dbPassword '***'
pulumi preview
pulumi up --yes
Minimal program sketch
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.BucketV2("assets", {
tags: { service: "api", env: pulumi.getStack() },
});
export const bucketName = bucket.id;
Stack operations
pulumi stack ls
pulumi stack output --json
pulumi refresh --yes
pulumi destroy --yes # only with explicit user approval
Import existing resource
pulumi import aws:s3/bucketV2:BucketV2 assets my-existing-bucket-name
Change-risk table
| Diff type | Risk | Agent action |
|---|---|---|
| Create | Low-Medium | Confirm naming/tags/region |
| Update in-place | Medium | Check security group / IAM blast radius |
| Replace | High | Call out downtime and data loss |
| Delete | High | Require explicit user confirmation |
Best practices
- One stack per environment; share code via Component Resources, not copy-paste.
- Enable policy packs / CI previews on PRs; block merge on unexpected deletes.
- Pin provider plugin versions in CI for reproducible plans.
- Use
protect: trueon production databases and critical DNS zones.
Limitations
- Preview is not a guarantee against provider eventual-consistency races.
- Large monorepos may need automation API or ESC for secrets at scale.
- Cross-cloud programs still need correct provider credentials per stack.
Related skills
gcloud-cli/azure-cli- imperative ops and auth debugging beside Pulumipacker- image baking referenced by compute resourceskubernetes- Pulumi k8s provider workloadsvault- external secret backends integrated with stacks