Use the Pulumi Automation API in Python to programmatically create and destroy ephemeral stacks with inline programs for integration test environments

domain: pulumi.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Import pulumi.automation and define an inline Pulumi program as a regular Python function that declares resources using the standard Pulumi SDK
  2. Call auto.create_or_select_stack with the inline_program parameter, passing the function and a unique stack name derived from the test run ID
  3. Set stack configuration values using stack.set_config for any environment-specific parameters, and set secrets using set_config with the is_secret flag
  4. Call stack.up() with an OnOutput callback to stream deployment logs, then extract stack outputs using stack.outputs() for use in test assertions
  5. In a teardown fixture, call stack.destroy() followed by stack.workspace.remove_stack() to clean up all resources and remove the stack from the Pulumi state backend

Known gotchas

Related routes

Use the Pulumi Automation API to build a CI script that provisions ephemeral preview environments per pull request and tears them down on merge
Pulumi · 6 steps · unrated
Write a Pulumi dynamic provider in Python to manage a custom API resource lifecycle with create, read, update, and delete operations
pulumi.com · 5 steps · unrated
Integrate hazardous-waste manifest workflows using the e-Manifest Python client library
USEPA e-manifest emanifest-py (github.com/USEPA/e-manifest) · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans