pulumi-hcl

module
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: Apache-2.0

README

Pulumi HCL Language Plugin

A Pulumi language plugin that enables running Pulumi against a Terraform HCL IaC program.

Overview

This plugin allows you to use familiar Terraform/HCL syntax while leveraging Pulumi's state management, secrets handling, and cloud platform. It parses HCL files and translates them to Pulumi resource registrations at runtime.

See the language reference for the full language spec.

# main.tf
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-unique-bucket-name"

  tags = {
    Environment = "dev"
    ManagedBy   = "Pulumi"
  }
}

output "bucket_arn" {
  value = aws_s3_bucket.my_bucket.arn
}

Installation

Pulumi HCL requires the pulumi CLI v3.256.0 or later. The CLI downloads the language and converter plugins automatically the first time you use them — there is nothing to install by hand.

To build the plugins from source for development, install them directly onto your path:

go install github.com/pulumi/pulumi-hcl/cmd/pulumi-language-hcl@latest  # for the language
go install github.com/pulumi/pulumi-hcl/cmd/pulumi-converter-hcl@latest # for the converter
go install github.com/pulumi/pulumi-hcl/cmd/pulumi-resource-hcl@latest # for the provider

Usage

  1. Create a Pulumi.yaml with runtime: hcl:
name: my-project
runtime: hcl
description: My HCL project
  1. Create HCL files (.tf extension):
# main.tf
resource "random_pet" "my_pet" {
  length = 2
}

output "pet_name" {
  value = random_pet.my_pet.id
}
  1. Run Pulumi commands as usual:
pulumi up

Terraform Compatibility

This plugin supports the majority of Terraform's HCL syntax. For detailed compatibility information and known limitations, see docs/terraform-compatibility.md.

Not Supported
  • backend, required_version, provider_meta, and experiments in the terraform block — accepted but ignored with a warning; Pulumi manages state independently
  • cloud blocks in the terraform block — not accepted at all; a cloud block is a parse error
  • WinRM connection blocks — connection supports type = "ssh" only
  • List<Object> empty vs null distinction: HCL block syntax cannot distinguish between an empty and null List<Object>, which is a known incompatibility with some Pulumi programs
Pulumi-Specific Extensions
# Stack references
resource "pulumi_stack_reference" "network" {
  name = "myorg/networking/prod"
}

output "vpc_id" {
  value = pulumi_stack_reference.network.outputs["vpc_id"]
}
# Method calls on resources
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-unique-bucket-name"
}

call "my_bucket" "get_object" {
  key = "config.json"
}

The call block invokes a method on an existing resource. The first label is the resource's logical name (matching a declared resource) and the second is the method name. Results are referenced as call.<resource>.<method>.<output>.

Three built-in functions provide access to a resource's Pulumi identity at runtime:

  • pulumiresourcename(resource) — returns the logical name from the resource's URN
  • pulumiresourcetype(resource) — returns the type token from the resource's URN
  • pulumiresourceurn(resource) — returns the resource's URN

License

Apache 2.0 - See LICENSE for details.

Note: This project uses github.com/hashicorp/hcl/v2 which is licensed under MPL 2.0.

Directories

Path Synopsis
cmd
pulumi-converter-hcl command
pulumi-converter-hcl converts between HCL and PCL (Pulumi Configuration Language).
pulumi-converter-hcl converts between HCL and PCL (Pulumi Configuration Language).
pulumi-language-hcl command
pulumi-language-hcl is the Pulumi language host for HCL (HashiCorp Configuration Language).
pulumi-language-hcl is the Pulumi language host for HCL (HashiCorp Configuration Language).
pulumi-resource-hcl command
pulumi-resource-hcl is the fully dynamic HCL resource provider.
pulumi-resource-hcl is the fully dynamic HCL resource provider.
pkg
converter
Package converter converts HCL programs to PCL (Pulumi Configuration Language).
Package converter converts HCL programs to PCL (Pulumi Configuration Language).
docs
Package docs provides language-specific helpers for rendering HCL in Pulumi schema-driven documentation.
Package docs provides language-specific helpers for rendering HCL in Pulumi schema-driven documentation.
grpcerr
Package grpcerr maps the errors pulumi-hcl produces onto gRPC status codes, so callers like `pulumi package get-schema` can classify a failure by its code instead of parsing message text.
Package grpcerr maps the errors pulumi-hcl produces onto gRPC status codes, so callers like `pulumi package get-schema` can classify a failure by its code instead of parsing message text.
hcl/ast
Package ast defines the Abstract Syntax Tree types for HCL configurations.
Package ast defines the Abstract Syntax Tree types for HCL configurations.
hcl/bridge
Package bridge resolves Terraform provider names to bridged tfbridge.ProviderInfo instances via the Pulumi convert.Mapper, so the engine can use original TF block/attribute layout when interpreting HCL.
Package bridge resolves Terraform provider names to bridged tfbridge.ProviderInfo instances via the Pulumi convert.Mapper, so the engine can use original TF block/attribute layout when interpreting HCL.
hcl/comments
Package comments associates source comments with the syntactic element that immediately follows them, so callers writing fresh hclwrite output can preserve comments from the original source.
Package comments associates source comments with the syntactic element that immediately follows them, so callers writing fresh hclwrite output can preserve comments from the original source.
hcl/eval
Package eval implements expression evaluation for HCL configurations.
Package eval implements expression evaluation for HCL configurations.
hcl/graph
Package graph implements dependency graph construction and topological sorting for HCL configuration execution ordering.
Package graph implements dependency graph construction and topological sorting for HCL configuration execution ordering.
hcl/modulepath
Package modulepath identifies a particular module instance in the nesting tree of an HCL configuration.
Package modulepath identifies a particular module instance in the nesting tree of an HCL configuration.
hcl/modules
Package modules loads and parses Terraform-compatible HCL module configurations.
Package modules loads and parses Terraform-compatible HCL module configurations.
hcl/packages
Package packages handles Pulumi package schema loading and type mapping.
Package packages handles Pulumi package schema loading and type mapping.
hcl/parser
Package parser implements HCL parsing for Terraform-compatible configurations.
Package parser implements HCL parsing for Terraform-compatible configurations.
hcl/resolve
Package resolve turns a module's provider requirements into concrete [workspace.PackageDescriptor]s using the engine's package-resolver service.
Package resolve turns a module's provider requirements into concrete [workspace.PackageDescriptor]s using the engine's package-resolver service.
hcl/run
Package run implements the HCL program execution engine.
Package run implements the HCL program execution engine.
hcl/schema
Package schema generates Pulumi package schemas from HCL module definitions.
Package schema generates Pulumi package schemas from HCL module definitions.
hcl/transform
Package transform handles conversion between cty values and Pulumi property values.
Package transform handles conversion between cty values and Pulumi property values.
provisioner/communicator/shared
Package shared replaces OpenTofu's internal/communicator/shared.
Package shared replaces OpenTofu's internal/communicator/shared.
provisioner/provisioners
Package provisioners shims the subset of OpenTofu's internal/provisioners the vendored communicator references.
Package provisioners shims the subset of OpenTofu's internal/provisioners the vendored communicator references.
provisioner/runtime
Package runtime executes TF-compatible provisioners in-process.
Package runtime executes TF-compatible provisioners in-process.
server
Package server implements the Pulumi language runtime gRPC server for HCL.
Package server implements the Pulumi language runtime gRPC server for HCL.
util
Package util provides utility types and functions.
Package util provides utility types and functions.
util/configs
Package configs is an in-tree shim for the one function of OpenTofu's internal/configs package that vendored/statefile's v3-state upgrade calls.
Package configs is an in-tree shim for the one function of OpenTofu's internal/configs package that vendored/statefile's v3-state upgrade calls.
util/encryption
Package encryption is an in-tree shim for the subset of OpenTofu's internal/encryption surface that vendored/statefile consumes.
Package encryption is an in-tree shim for the subset of OpenTofu's internal/encryption surface that vendored/statefile consumes.
util/httpclient
Package httpclient is the in-tree replacement for opentofu's internal/httpclient package.
Package httpclient is the in-tree replacement for opentofu's internal/httpclient package.
util/tracing
Package tracing is the in-tree replacement for opentofu's internal/tracing package.
Package tracing is the in-tree replacement for opentofu's internal/tracing package.
util/tracing/traceattrs
Package traceattrs is the in-tree replacement for opentofu's internal/tracing/traceattrs package.
Package traceattrs is the in-tree replacement for opentofu's internal/tracing/traceattrs package.
version
Package version provides version information for the HCL language plugin.
Package version provides version information for the HCL language plugin.
sdk
go module
tests
testutil/mlctest
Package mlctest is the component half of putest: it runs a YAML program that consumes one local HCL component directory, pins the component's package schema against a golden file, and asserts on stack outputs, exported Pulumi state, and recorded provider operations.
Package mlctest is the component half of putest: it runs a YAML program that consumes one local HCL component directory, pins the component's package schema against a golden file, and asserts on stack outputs, exported Pulumi state, and recorded provider operations.
testutil/pulexec
Package pulexec runs a Pulumi program through the real Pulumi engine and `pulumi-language-hcl` runtime, attaching bridged TF providers in-process.
Package pulexec runs a Pulumi program through the real Pulumi engine and `pulumi-language-hcl` runtime, attaching bridged TF providers in-process.
testutil/putest
Package putest is the Pulumi-only half of the tfcompat harness: it runs a `.tf` program from testdata/cases/<name>/ through `pulumi up` against in-process bridged providers (pulexec's attach path), asserting directly on stack outputs, exported Pulumi state, and recorded provider operations.
Package putest is the Pulumi-only half of the tfcompat harness: it runs a `.tf` program from testdata/cases/<name>/ through `pulumi up` against in-process bridged providers (pulexec's attach path), asserting directly on stack outputs, exported Pulumi state, and recorded provider operations.
testutil/sshd
Package sshd starts a containerized OpenSSH server for tests that need a real SSH endpoint.
Package sshd starts a containerized OpenSSH server for tests that need a real SSH endpoint.
testutil/tfcompat
Package tfcompat is the Terraform-compatibility test harness.
Package tfcompat is the Terraform-compatibility test harness.
testutil/tfcompat/providers
Package providers holds reusable in-memory TF providers for tfcompat tests.
Package providers holds reusable in-memory TF providers for tfcompat tests.
testutil/tfexec
Package tfexec drives the Terraform/OpenTofu CLI against in-process TF providers (via reattach) so tests can exercise real Terraform behavior without installing remote provider binaries.
Package tfexec drives the Terraform/OpenTofu CLI against in-process TF providers (via reattach) so tests can exercise real Terraform behavior without installing remote provider binaries.
Package vendored holds third-party code copied verbatim from upstream projects and re-imported under our module path.
Package vendored holds third-party code copied verbatim from upstream projects and re-imported under our module path.
addrs
Package addrs contains types that represent "addresses", which are references to specific objects within a OpenTofu configuration or state.
Package addrs contains types that represent "addresses", which are references to specific objects within a OpenTofu configuration or state.
getmodules
Package getmodules contains the low-level functionality for fetching remote module packages.
Package getmodules contains the low-level functionality for fetching remote module packages.
ipaddr
Package ipaddr is a fork of a subset of the Go standard "net" package which retains parsing behaviors from Go 1.16 or earlier.
Package ipaddr is a fork of a subset of the Go standard "net" package which retains parsing behaviors from Go 1.16 or earlier.
legacy/hcl2shim
Package hcl2shim contains a small number of "shimming" utilities that the other packages under internal/legacy use to adapt from HCL 2 concepts to legacy concepts.
Package hcl2shim contains a small number of "shimming" utilities that the other packages under internal/legacy use to adapt from HCL 2 concepts to legacy concepts.
statefile
Package statefile deals with the file format used to serialize states for persistent storage and then deserialize them into memory again later.
Package statefile deals with the file format used to serialize states for persistent storage and then deserialize them into memory again later.
states
Package states contains the types that are used to represent OpenTofu states.
Package states contains the types that are used to represent OpenTofu states.
tfdiags
Package tfdiags is a utility package for representing errors and warnings in a manner that allows us to produce good messages for the user.
Package tfdiags is a utility package for representing errors and warnings in a manner that allows us to produce good messages for the user.
version
The version package provides a location to set the release versions for all packages to consume, without creating import cycles.
The version package provides a location to set the release versions for all packages to consume, without creating import cycles.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL