Pulumi Terraform Provider
The Terraform resource provider for Pulumi lets you consume the outputs
contained in Terraform state files from your Pulumi programs. The package
provides a RemoteStateReference resource which acts like a native Pulumi
StackReference.
To use this package, please install the Pulumi CLI first.
Installing
Node.js (JavaScript/TypeScript)
To use from JavaScript or TypeScript in Node.js, install using either npm:
$ npm install @pulumi/terraform
or yarn:
$ yarn add @pulumi/terraform
Python
To use from Python, install using pip:
$ pip install pulumi-terraform
Concepts
The @pulumi/terraform package provides a resource named RemoteStateReference
which is used to read outputs from a Terraform state file stored in one of the
supported Terraform remote state backends.
Examples
S3
The following program will read a Terraform state file stored in S3:
import * as tf from "@pulumi/terraform";
const remoteState = new tf.state.RemoteStateReference("s3state", {
backendType: "s3",
bucket: "pulumi-terraform-state-test",
key: "test/terraform.tfstate",
region: "us-west-2"
});
// Use the getOutput function on the resource to access root outputs
const vpcId= remoteState.getOutput("vpc_id");
Local file
The following program will read a Terraform state file stored locally in the filesystem:
import * as tf from "@pulumi/terraform";
const remotestate = new tf.state.RemoteStateReference("localstate", {
backendType: "local",
path: path.join(__dirname, "terraform.tfstate"),
});
// Use the getOutput function on the resource to access root outputs
const vpcId= remoteState.getOutput("vpc_id");
Terraform Enterprise
For state stored in Terraform Enterprise, the authentication token must be set via the Pulumi configuration system - for example, using:
pulumi config set --secret terraformEnterpriseToken <value>
The following program will read a Terraform state file stored in Terraform
Enterprise, using the value of terraformEnterpriseToken from above:
import * as pulumi from "@pulumi/pulumi";
import * as tf from "@pulumi/terraform";
const config = new pulumi.Config();
const ref = new tf.state.RemoteStateReference("remote", {
backendType: "remote",
organization: "pulumi",
token: config.requireSecret("terraformEnterpriseToken"),
workspaces: {
name: "test-state-file"
}
});
// Use the getOutput function on the resource to access root outputs
const vpcId= remoteState.getOutput("vpc_id");
Release files for pulumi-terraform 4.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pulumi_terraform-4.4.0.tar.gz | 11.1 kB | Details |
Release files / pulumi_terraform-4.4.0.tar.gz
| Download URL | pulumi_terraform-4.4.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c28d5216a73036bee18723aa00343b8071b6454ce5ea66b12a17ed3064a9d5b5
|
|
BLAKE2b-256 checksum How to use checksums |
81ffd86b4990c0c6096c2f5aa13f3a774f4e7ed82df7bfd393a524e17d2ee932
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|