Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Pulumi Difficulty: Intermediate ClaudeChatGPT

Pulumi Unit & Integration Testing Prompt

Design a Pulumi test strategy — fast unit tests with mocks plus real integration tests — so component logic and deployed behavior are both verified before infrastructure changes ship.

Target user
Engineers adding automated tests to a Pulumi codebase
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior engineer who treats infrastructure code like application code and refuses to ship it untested.

I will provide:
- Language and test framework preference (Jest/Mocha, pytest, Go testing, xUnit)
- The components/programs I want to cover and their critical invariants (tagging, encryption, network exposure)
- Whether ephemeral test infrastructure and cloud credentials are available for integration tests
- My CI system

Your job:

1. **Layer the strategy** — separate fast unit tests (mocked, no cloud calls) from integration tests (real `pulumi up` in an ephemeral stack) and property/policy tests. Say what each layer should and shouldn't catch.

2. **Unit tests with mocks** — use Pulumi's mocking (`setMocks` / `pulumi.runtime` mocks) to instantiate a program in-memory and assert resource inputs: required tags present, encryption enabled, no `0.0.0.0/0` ingress. Show one concrete example asserting a component's child-resource props.

3. **Integration tests** — use the Automation API (or the test harness) to deploy an ephemeral stack, assert real outputs/behavior, then reliably tear it down even on failure. Show the setup/teardown skeleton.

4. **What to assert** — focus on invariants that matter (security posture, naming, output shape) rather than snapshotting every attribute, which produces brittle tests.

5. **CI wiring** — run unit tests on every PR (no credentials needed), gate integration tests behind a separate job with scoped credentials and guaranteed cleanup.

6. **Flakiness & cost control** — keep integration stacks small, unique-named, and always destroyed; budget for the cloud cost of the integration suite.

Output as: (a) the test-layer strategy table, (b) a mocked unit-test example in my language, (c) an integration-test setup/teardown skeleton, (d) the CI job split, (e) a list of the highest-value invariants to assert first.

Bias toward: fast mocked tests for logic, a few high-value integration tests for real behavior, and guaranteed teardown so tests never leak cloud resources.

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

More Pulumi prompts & error guides

Browse every Pulumi prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.