published on Wednesday, Aug 19, 2026 by Pulumi
Any HCL Module
published on Wednesday, Aug 19, 2026 by Pulumi
The hcl package lets you instantiate any Terraform or OpenTofu module as a
Pulumi component resource.
Point the Module resource at a module source — a Terraform registry reference,
a Git URL, or a local path — pass its input variables, and consume its outputs
like any other Pulumi resource, from any supported language.
The module runs under Pulumi’s engine: its resources are tracked in your Pulumi state, its provider credentials come from your Pulumi configuration, and its sensitive outputs are handled as Pulumi secrets.
Example
The following program instantiates the community
terraform-aws-modules/vpc/aws
module and exports the resulting VPC id.
import * as pulumi from "@pulumi/pulumi";
import * as hcl from "@pulumi/hcl";
const vpc = new hcl.Module("vpc", {
source: "terraform-aws-modules/vpc/aws",
version: "5.0.0",
inputs: {
name: "example-vpc",
cidr: "10.0.0.0/16",
},
});
export const vpcId = vpc.outputs.apply(o => o["vpc_id"]);
import pulumi
import pulumi_hcl as hcl
vpc = hcl.Module("vpc",
source="terraform-aws-modules/vpc/aws",
version="5.0.0",
inputs={
"name": "example-vpc",
"cidr": "10.0.0.0/16",
})
pulumi.export("vpc_id", vpc.outputs["vpc_id"])
package main
import (
"github.com/pulumi/pulumi-hcl/sdk/go/hcl"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
vpc, err := hcl.NewModule(ctx, "vpc", &hcl.ModuleArgs{
Source: "terraform-aws-modules/vpc/aws",
Version: pulumi.StringRef("5.0.0"),
Inputs: pulumi.Map{
"name": pulumi.String("example-vpc"),
"cidr": pulumi.String("10.0.0.0/16"),
},
})
if err != nil {
return err
}
ctx.Export("vpcId", vpc.Outputs.MapIndex(pulumi.String("vpc_id")))
return nil
})
}
using System.Collections.Generic;
using Pulumi;
using Pulumi.Hcl;
return await Deployment.RunAsync(() =>
{
var vpc = new Module("vpc", new ModuleArgs
{
Source = "terraform-aws-modules/vpc/aws",
Version = "5.0.0",
Inputs =
{
{ "name", "example-vpc" },
{ "cidr", "10.0.0.0/16" },
},
});
return new Dictionary<string, object?>
{
["vpcId"] = vpc.Outputs.Apply(o => o["vpc_id"]),
};
});
package myproject;
import com.pulumi.Pulumi;
import com.pulumi.hcl.Module;
import com.pulumi.hcl.ModuleArgs;
import java.util.Map;
public class App {
public static void main(String[] args) {
Pulumi.run(ctx -> {
var vpc = new Module("vpc", ModuleArgs.builder()
.source("terraform-aws-modules/vpc/aws")
.version("5.0.0")
.inputs(Map.of(
"name", "example-vpc",
"cidr", "10.0.0.0/16"))
.build());
ctx.export("vpcId", vpc.outputs().applyValue(o -> o.get("vpc_id")));
});
}
}
name: example
runtime: yaml
resources:
vpc:
type: hcl:index:Module
properties:
source: terraform-aws-modules/vpc/aws
version: "5.0.0"
inputs:
name: example-vpc
cidr: 10.0.0.0/16
outputs:
vpcId: ${vpc.outputs["vpc_id"]}
Strongly typed SDKs
The Module resource above takes its source at runtime, so its inputs and
outputs are untyped maps. To get a strongly typed SDK for a specific module,
generate a parameterized provider for it:
pulumi package add hcl module <source> [version] [--name <name>]
For example, pulumi package add hcl module terraform-aws-modules/vpc/aws 5.0.0
generates a local SDK whose resource exposes that module’s variables and outputs
as first-class, typed properties in your language of choice.
By default the package is named after the module name and its system (vpc-aws in the
example above). Pass --name to choose a different package name:
pulumi package add hcl module terraform-aws-modules/vpc/aws 5.0.0 --name vpc
published on Wednesday, Aug 19, 2026 by Pulumi