Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pulumi/pulumi-terraform
A resource package that allows Pulumi programs to use Terraform state
https://github.com/pulumi/pulumi-terraform
Last synced: 7 days ago
JSON representation
A resource package that allows Pulumi programs to use Terraform state
- Host: GitHub
- URL: https://github.com/pulumi/pulumi-terraform
- Owner: pulumi
- License: apache-2.0
- Created: 2017-06-26T21:49:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-20T11:18:07.000Z (5 months ago)
- Last Synced: 2024-12-29T01:11:43.504Z (14 days ago)
- Language: Go
- Homepage:
- Size: 2.51 MB
- Stars: 112
- Watchers: 25
- Forks: 18
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG_OLD.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE-OF-CONDUCT.md
Awesome Lists containing this project
- awesome - pulumi-terraform - A bridge between Pulumi and Terraform (Python)
README
# 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`][stackreference].To use this package, please [install the Pulumi CLI first][pulumicli].
## 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
### PythonTo use from Python, install using `pip`:
$ pip install pulumi-terraform
## Concepts
The `@pulumi/terraform` package provides a [resource](https://www.pulumi.com/docs/concepts/resources/) 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:
```typescript
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:```typescript
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
The following program will read a Terraform state file stored in Terraform
Enterprise, using the value of `terraformEnterpriseToken` from above:```typescript
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");
```[stackreference]: https://www.pulumi.com/docs/reference/organizing-stacks-projects/#inter-stack-dependencies
[pulumicli]: https://pulumi.com/