Skip to main content
Pulumi logo Pulumi logo
  1. Docs
  2. Integrations
  3. Terraform & OpenTofu

Terraform & OpenTofu

    Pulumi works alongside your existing Terraform and OpenTofu investment. You don’t have to migrate everything at once, or at all: Pulumi Cloud can manage your Terraform state and runs, Pulumi programs can use Terraform providers, modules, and state directly, and you can convert HCL to Pulumi when and where it makes sense.

    This page links to every Pulumi capability for Terraform and OpenTofu users. If you’re new to Pulumi, start by installing Pulumi and following a get-started guide for your cloud.

    Terraform and Pulumi side by side

    Here’s a Terraform configuration that looks up the latest Ubuntu AMI:

    data "aws_ami" "ubuntu" {
      region      = "us-west-2"
      most_recent = true
      owners      = ["099720109477"] # Canonical
    
      filter {
        name   = "name"
        values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
      }
    }
    
    output "latest_ubuntu_ami_id" {
      value = data.aws_ami.ubuntu.id
    }
    

    The same program in TypeScript:

    import * as aws from "@pulumi/aws";
    
    const ubuntu = aws.ec2.getAmiOutput({
        region: "us-west-2",
        mostRecent: true,
        owners: ["099720109477"],
        filters: [{
            name: "name",
            values: ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"],
        }],
    });
    
    export const latestUbuntuAmiId = ubuntu.id;
    

    Pulumi programs can be written in TypeScript, JavaScript, Python, Go, .NET, Java, or YAML. You can also keep writing HCL: with the Pulumi HCL runtime, the Terraform configuration above runs unchanged under the Pulumi engine. For a concept-by-concept mapping, see Terraform terminology.

    Pulumi Cloud for Terraform

    Use Pulumi Cloud as the backend and control plane for Terraform and OpenTofu configurations you keep as they are.

    • Store Terraform state in Pulumi Cloud: use Pulumi Cloud as your state backend, with update history, state locking, RBAC, audit policies, and unified resource visibility.
    • Remote execution: run Terraform and OpenTofu plans and applies on Pulumi Cloud, with credentials from Pulumi ESC and VCS-triggered runs.
    • Terraform module registry: publish and consume Terraform modules in Pulumi Cloud through an HCP-compatible registry, with each module also available as a Pulumi package.

    Use Terraform from Pulumi

    Bring the Terraform ecosystem into Pulumi programs.

    • Any Terraform provider: use any Terraform or OpenTofu provider in a Pulumi program, including providers with no pre-built Pulumi package.
    • Terraform modules: use existing Terraform modules directly, with generated, typed SDKs.
    • Reference Terraform state: read outputs from Terraform state files so Pulumi and Terraform can manage infrastructure side by side.

    Convert and orchestrate

    Secrets and configuration

    Migrate and compare

      The infrastructure as code platform for any cloud.