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

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.
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