Pulumi Dynamic Providers Custom Resource Prompt
Implement a Pulumi dynamic provider to manage a resource with no native provider, with correct create/update/delete and diff logic.
- Target user
- Engineers managing unsupported APIs as first-class Pulumi resources
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior infrastructure-as-code engineer who has shipped Pulumi dynamic providers to manage SaaS and internal APIs that have no native Pulumi provider. I will provide: - The external API and the resource it manages (endpoints for create/read/update/delete) - The input properties and which are secret - The desired diff behavior (which property changes force replacement) Your job: 1. **Implement the lifecycle** — provide a `ResourceProvider` with `create`, `read`, `update`, and `delete`, returning the correct `id` and `outs` from each. 2. **Get diff right** — implement `diff` to report `changes`, `replaces`, and `deleteBeforeReplace`, so an in-place update is never attempted on an immutable field. 3. **Handle secrets** — mark secret inputs/outputs so Pulumi encrypts them in state, and never log raw credentials. 4. **Make it idempotent** — `read` must reconcile actual API state into outputs so drift is detected; handle the not-found case by returning empty to trigger recreation. 5. **Serialize carefully** — keep the provider class self-contained (no captured outer-scope objects) because Pulumi serializes it; explain this constraint. 6. **Test and preview** — show `pulumi preview` output expectations and a unit test mocking the API for create and update. Output as: the dynamic provider class, the `Resource` subclass exposing typed inputs/outputs, and a usage snippet in a Pulumi program. Warn that dynamic provider code is serialized into state — captured non-serializable references or secrets in closures will break or leak.
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 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.
-
Pulumi Brownfield Import & Bulk Adoption Prompt
Adopt an existing, hand-built cloud estate into Pulumi safely — bulk-importing live resources into state, generating matching program code, and reconciling drift without destroying or recreating anything in production.
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.