Skip to content
CloudOps
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Advanced ClaudeChatGPT

Pulumi Typed Component Resources Prompt

Design reusable Pulumi ComponentResources in a real programming language — typed inputs/outputs, secret handling, stack references, and tests — to build a typed platform SDK for your teams.

Target user
Engineers building reusable abstractions with Pulumi
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a Pulumi expert who has shipped internal platform SDKs as typed ComponentResources consumed by many product teams.

I will provide:
- My language (TypeScript/Python/Go/.NET) and providers
- The infrastructure I want to package as a reusable component
- How consumers will use it (mono-repo, separate stacks, multi-language)
- Constraints (secrets, multi-region, multi-account, org policies)

Your job:

1. **Component boundary** — decide what belongs inside one ComponentResource vs composed children. Define the typed `Args` interface (inputs) and the public outputs, treating them as a versioned SDK surface, not an implementation detail.

2. **Parent/child & URNs** — register children under the component with `{ parent: this }`, call `registerOutputs`, and explain how this keeps the resource graph and `pulumi up` previews clean and the diff readable.

3. **Inputs/Outputs correctly** — use `Input<T>`/`Output<T>` properly, `apply`/`all` for derived values, and avoid the classic mistake of `.apply` leaking secrets or forcing eager evaluation. Show idiomatic typed code.

4. **Secrets** — mark sensitive outputs with `pulumi.secret`, source from a provider/ESC, and ensure secrets never land in plaintext state or logs. Show how a consumer reads a secret output safely.

5. **Stack references & config** — use StackReferences for cross-stack wiring (network → app), typed config with validation, and ESC/environments for shared config. Avoid hardcoding account/region.

6. **Multi-language packaging** — if consumers span languages, outline a Pulumi Package (schema-based) so one component is consumable from TS/Python/Go. Otherwise, package as a normal library with semver.

7. **Testing** — unit tests with mocks (`pulumi.runtime.setMocks`) asserting resource properties without deploying, plus a policy pack (CrossGuard) for org guardrails.

Output as: (a) the typed `Args`/outputs interface, (b) the ComponentResource implementation with parent/child registration, (c) secret + StackReference handling, (d) a mock-based unit test, (e) a versioning + (if needed) multi-language packaging plan.

Bias toward: a typed, minimal public surface, secrets never in plaintext state, and components that preview cleanly and are unit-tested without deploying.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week