Provision Resources During Deployment
Combine IaCM and CD stages to provision infrastructure and deploy applications in a single pipeline.
Create a single pipeline to provision or update resources during deployment. This pattern combines IaCM and CD stages in a single pipeline, allowing you to provision infrastructure and then deploy applications that use those resources.
Before you begin
Harness account with IaCM and CD enabled: You need both Infrastructure as Code Management and Continuous Delivery modules. For how to access or create a Harness account, go to Getting started with Harness Platform.
Pipeline permissions: You need View, Create/Edit, and Execute for Pipelines. To get these, an administrator must assign you a role that includes them. Go to RBAC in Harness and Manage roles.
IaCM workspace configured: You need an existing workspace with Terraform or OpenTofu configuration. Go to Create a workspace to set one up.
Pipeline stages overview
A combined IaCM and CD pipeline includes two stages:
IaCM Stage: This stage provisions or updates resources, setting the groundwork for your deployment.
CD Stage: This stage uses the resources provisioned in the IaCM stage to deploy your application.
Go to CD steps, stages, and strategies for information about CD stages.
Pass variables between stages
You can pass variables from an IaCM pipeline to a CD stage. For example, pass the Kubernetes namespace as a value.
After executing a pipeline, select the Apply step to view all OpenTofu or Terraform outputs as output expressions. Copy these for use in subsequent steps or stages, even across different pipelines.

Example: pass a variable
To use the "bucket_name" as an input, copy the current value or the path to the variables. This ensures the value is fetched at runtime:

Troubleshooting
Next steps
You have successfully combined IaCM and CD stages in a single pipeline. You can now provision infrastructure and deploy applications in one workflow.
Go to Approval step to add manual approval gates before applying infrastructure changes.
Go to OPA policies to enforce governance rules during pipeline execution.
Go to Default pipelines to configure reusable pipeline templates.
Last updated
Was this helpful?