Dynamic Environment Provisioner for CI/CD
An automation script in a CI/CD pipeline that uses the Automation API to create ephemeral environments for testing pull requests.
Overview
This pattern involves integrating the Pulumi Automation API into a CI/CD pipeline (like GitHub Actions) to manage dynamic, per-pull-request environments. When a developer opens a pull request, a CI job is triggered. This job runs a script that uses the Automation API to create a new stack (e.g., `pr-123`), deploy a complete, isolated copy of the application and its infrastructure, and post the endpoint URL back to the PR. This allows for comprehensive testing against live infrastructure. When the PR is merged or closed, another job is triggered that calls the Automation API to destroy the stack, ensuring no resources are left running.
✨ Key Features
- Creates ephemeral infrastructure environments on-demand.
- Integrates directly into CI/CD pipelines.
- Programmatically manages stack lifecycle (create, update, destroy).
- Provides isolated environments for each pull request.
- Automates cleanup of temporary resources.
🎯 Key Differentiators
- Provisions the entire infrastructure stack, not just the frontend application.
- Offers full programmatic control within the CI/CD job using a real programming language.
- Cloud-agnostic, can create preview environments on any cloud.
Unique Value: Enables high-confidence testing and review by creating a complete, ephemeral copy of the production environment for every pull request.
🎯 Use Cases (3)
✅ Best For
- Pulumi's own GitHub Action is powered by the Automation API, giving users control over Pulumi workflows in CI/CD.
- Tutorials demonstrate modifying an Azure DevOps pipeline to remove dependency on the Pulumi CLI and use a .NET application with the Automation API instead.
💡 Check With Vendor
Verify these considerations match your specific requirements:
- Projects where preview environments are not necessary or are too costly to create.
- Simple applications that can be tested sufficiently with local mocks.
🏆 Alternatives
Using the Automation API is more robust and flexible than wrapping CLI commands in shell scripts, as it allows for complex logic, better error handling, and a cleaner integration with the CI/CD system's programming environment.
💻 Platforms
🔌 Integrations
💰 Pricing
Free tier: This is a CI/CD pattern; cost is based on CI/CD runner minutes and the ephemeral cloud resources provisioned.
🔄 Similar Tools in Pulumi Automation API
Pulumi
An open-source infrastructure-as-code platform for creating, deploying, and managing cloud infrastru...
Pulumi Kubernetes Operator
A Kubernetes controller that manages Pulumi stacks as custom resources, enabling GitOps workflows fo...
Self-Service Infrastructure Platform
An internal tool, often a web portal or CLI, that uses the Automation API to expose standardized inf...
Infrastructure Integration Testing Framework
Using Automation API within a testing framework (like Pytest or Mocha) to programmatically manage in...
Custom Infrastructure CLI
A custom CLI tool that wraps Pulumi operations to provide a user-friendly, domain-specific interface...
Multi-Stack Orchestration Engine
A custom application that uses the Automation API to coordinate complex workflows involving several ...