|
| 1 | +--- |
| 2 | +title_tag: terraform-state Pulumi ESC Provider |
| 3 | +meta_desc: The terraform-state provider enables you to read outputs from Terraform state files stored in S3 or Terraform Cloud. |
| 4 | +title: terraform-state |
| 5 | +h1: terraform-state |
| 6 | +menu: |
| 7 | + esc: |
| 8 | + identifier: terraform-state |
| 9 | + parent: esc-terraform-integrations |
| 10 | + weight: 1 |
| 11 | +aliases: |
| 12 | + - /docs/pulumi-cloud/esc/providers/terraform-state/ |
| 13 | + - /docs/esc/providers/terraform-state/ |
| 14 | +--- |
| 15 | + |
| 16 | +The `terraform-state` provider enables you to read outputs from Terraform state files stored in S3 or Terraform Cloud. |
| 17 | + |
| 18 | +## Example |
| 19 | + |
| 20 | +### S3 backend |
| 21 | + |
| 22 | +```yaml |
| 23 | +values: |
| 24 | + terraform: |
| 25 | + fn::open::terraform-state: |
| 26 | + backend: |
| 27 | + s3: |
| 28 | + login: |
| 29 | + fn::open::aws-login: |
| 30 | + oidc: |
| 31 | + roleArn: arn:aws:iam::123456789012:role/esc-oidc |
| 32 | + sessionName: pulumi-environments-session |
| 33 | + bucket: my-terraform-state-bucket |
| 34 | + key: path/to/terraform.tfstate |
| 35 | + region: us-west-2 |
| 36 | + pulumiConfig: |
| 37 | + vpcId: ${terraform.outputs.vpc_id} |
| 38 | + subnetIds: ${terraform.outputs.subnet_ids} |
| 39 | +``` |
| 40 | +
|
| 41 | +### Terraform Cloud backend |
| 42 | +
|
| 43 | +```yaml |
| 44 | +values: |
| 45 | + terraform: |
| 46 | + fn::open::terraform-state: |
| 47 | + backend: |
| 48 | + remote: |
| 49 | + organization: my-terraform-org |
| 50 | + workspace: my-workspace |
| 51 | + token: |
| 52 | + fn::secret: tfc-token-value |
| 53 | + pulumiConfig: |
| 54 | + vpcId: ${terraform.outputs.vpc_id} |
| 55 | + subnetIds: ${terraform.outputs.subnet_ids} |
| 56 | +``` |
| 57 | +
|
| 58 | +## Inputs |
| 59 | +
|
| 60 | +| Property | Type | Description | |
| 61 | +|-----------|---------------------|---------------------------------------------------------------| |
| 62 | +| `backend` | [Backend](#backend) | Configuration for the Terraform state backend (S3 or remote). | |
| 63 | + |
| 64 | +### Backend |
| 65 | + |
| 66 | +The `backend` property must contain exactly one of the following: |
| 67 | + |
| 68 | +- An [S3 backend configuration](#s3), or |
| 69 | +- a [remote](#remote) backend configuration. |
| 70 | + |
| 71 | +#### S3 |
| 72 | + |
| 73 | +| Property | Type | Description | |
| 74 | +|----------|--------------------------------------------------------------------------|--------------------------------------------------| |
| 75 | +| `login` | [aws-login](/docs/esc/integrations/dynamic-login-credentials/aws-login/) | The credentials to use to access the state file. | |
| 76 | +| `bucket` | string | The S3 bucket name containing the state file. | |
| 77 | +| `key` | string | The S3 object key for the state file. | |
| 78 | +| `region` | string | The AWS region where the bucket is located. | |
| 79 | + |
| 80 | +#### Remote |
| 81 | + |
| 82 | +| Property | Type | Description | |
| 83 | +|----------------|--------|-----------------------------------------------------------------------------------------| |
| 84 | +| `hostname` | string | [Optional] - The remote backend hostname to connect to. Defaults to `app.terraform.io`. | |
| 85 | +| `organization` | string | The name of the organization containing the targeted workspace. | |
| 86 | +| `workspace` | string | The name of the remote workspace. | |
| 87 | +| `token` | string | The token used to authenticate with the remote backend. | |
| 88 | + |
| 89 | +## Outputs |
| 90 | + |
| 91 | +| Property | Type | Description | |
| 92 | +|-----------|--------|----------------------------------------------------------------------------------------------------------------------| |
| 93 | +| `outputs` | object | A map of all outputs from the Terraform state. Any output marked as sensitive in the terraform state will be secret. | |
0 commit comments