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.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Pulumi Automation API Self-Service Prompt
Build an embedded self-service platform with the Pulumi Automation API — programmatic stack up/destroy, parameterized environments, and guardrails — instead of shelling out to the CLI in CI.
-
Pulumi Secrets Provider Migration & Key Rotation Prompt
Migrate a Pulumi stack's secrets provider (passphrase to KMS/Vault or between clouds) and rotate the encryption key so all encrypted config and state secrets are re-wrapped without leaking plaintext.
-
Pulumi Transformations & Aliases Refactor Prompt
Refactor Pulumi resource names, parents, and structure at scale using aliases and stack transformations so URNs change on paper but no live resource is destroyed or replaced.
-
Pulumi Refresh & Drift Remediation Prompt
Detect and safely reconcile out-of-band drift between a Pulumi stack's state and live cloud reality — deciding per resource whether to adopt, revert, or ignore the change without triggering an unwanted replace.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.