# 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
### 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:
```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 <value>
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/
Raw data
{
"_id": null,
"home_page": "https://pulumi.io",
"name": "pulumi-terraform",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pulumi terraform",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/99/80/ce2312b440593df737b3a3877067bc34538d5ff8d69cf3899a1e95d9167e/pulumi_terraform-5.13.4.tar.gz",
"platform": null,
"description": "# Pulumi Terraform Provider\n\nThe Terraform resource provider for Pulumi lets you consume the outputs\ncontained in Terraform state files from your Pulumi programs. The package\nprovides a `RemoteStateReference` resource which acts like a native Pulumi\n[`StackReference`][stackreference].\n\nTo use this package, please [install the Pulumi CLI first][pulumicli].\n\n## Installing\n\n### Node.js (JavaScript/TypeScript)\n\nTo use from JavaScript or TypeScript in Node.js, install using either `npm`:\n\n $ npm install @pulumi/terraform\n\nor `yarn`:\n\n $ yarn add @pulumi/terraform\n \n### Python\n\nTo use from Python, install using `pip`:\n\n $ pip install pulumi-terraform\n\n## Concepts\n\nThe `@pulumi/terraform` package provides a resource named `RemoteStateReference`\nwhich is used to read outputs from a Terraform state file stored in one of the\nsupported Terraform remote state backends.\n\n## Examples\n\n### S3\n\nThe following program will read a Terraform state file stored in S3:\n\n```typescript\nimport * as tf from \"@pulumi/terraform\";\n\nconst remoteState = new tf.state.RemoteStateReference(\"s3state\", {\n backendType: \"s3\",\n bucket: \"pulumi-terraform-state-test\",\n key: \"test/terraform.tfstate\",\n region: \"us-west-2\"\n});\n\n// Use the getOutput function on the resource to access root outputs\nconst vpcId= remoteState.getOutput(\"vpc_id\");\n```\n\n### Local file\n\nThe following program will read a Terraform state file stored locally in the\nfilesystem:\n\n```typescript\nimport * as tf from \"@pulumi/terraform\";\n\nconst remotestate = new tf.state.RemoteStateReference(\"localstate\", {\n backendType: \"local\",\n path: path.join(__dirname, \"terraform.tfstate\"),\n});\n\n// Use the getOutput function on the resource to access root outputs\nconst vpcId= remoteState.getOutput(\"vpc_id\");\n```\n\n### Terraform Enterprise\n\nFor state stored in Terraform Enterprise, the authentication token must be set\nvia the Pulumi configuration system - for example, using:\n\n pulumi config set --secret terraformEnterpriseToken <value>\n\nThe following program will read a Terraform state file stored in Terraform\nEnterprise, using the value of `terraformEnterpriseToken` from above:\n\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as tf from \"@pulumi/terraform\";\n\nconst config = new pulumi.Config();\n\nconst ref = new tf.state.RemoteStateReference(\"remote\", {\n backendType: \"remote\",\n organization: \"pulumi\",\n token: config.requireSecret(\"terraformEnterpriseToken\"),\n workspaces: {\n name: \"test-state-file\"\n }\n});\n\n// Use the getOutput function on the resource to access root outputs\nconst vpcId= remoteState.getOutput(\"vpc_id\");\n```\n\n[stackreference]: https://www.pulumi.com/docs/reference/organizing-stacks-projects/#inter-stack-dependencies\n[pulumicli]: https://pulumi.com/",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A Pulumi package for consuming Terraform Remote State resources.",
"version": "5.13.4",
"project_urls": {
"Homepage": "https://pulumi.io",
"Repository": "https://github.com/pulumi/pulumi-terraform"
},
"split_keywords": [
"pulumi",
"terraform"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9980ce2312b440593df737b3a3877067bc34538d5ff8d69cf3899a1e95d9167e",
"md5": "536272e0b17e5a96386728ed8c4543b6",
"sha256": "244544890ee0284076c1b69749130d668b7db076d34ad57964d39df9ac991d0a"
},
"downloads": -1,
"filename": "pulumi_terraform-5.13.4.tar.gz",
"has_sig": false,
"md5_digest": "536272e0b17e5a96386728ed8c4543b6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12150,
"upload_time": "2023-08-09T22:54:44",
"upload_time_iso_8601": "2023-08-09T22:54:44.547406Z",
"url": "https://files.pythonhosted.org/packages/99/80/ce2312b440593df737b3a3877067bc34538d5ff8d69cf3899a1e95d9167e/pulumi_terraform-5.13.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-09 22:54:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pulumi",
"github_project": "pulumi-terraform",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pulumi-terraform"
}