├── .ci-mgmt.yaml ├── .github └── workflows │ ├── build.yml │ ├── command-dispatch.yml │ ├── prerelease.yml │ ├── pull-request.yml │ ├── release.yml │ ├── run-acceptance-tests.yml │ └── weekly-pulumi-update.yml ├── .gitignore ├── .golangci.yml ├── .goreleaser.prerelease.yml ├── .goreleaser.yml ├── .pulumi.version ├── CHANGELOG_OLD.md ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── docs └── _index.md ├── examples ├── examples_dotnet_test.go ├── examples_go_test.go ├── examples_java_test.go ├── examples_nodejs_test.go ├── examples_python_test.go ├── examples_test.go ├── examples_yaml_test.go ├── local │ ├── dotnet │ │ ├── .gitignore │ │ ├── Program.cs │ │ ├── Pulumi.yaml │ │ ├── dotnet.csproj │ │ └── terraform.0-12-24.tfstate │ ├── go │ │ ├── Pulumi.yaml │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ └── terraform.0-12-24.tfstate │ ├── java │ │ ├── Pulumi.yaml │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── myproject │ │ │ │ └── App.java │ │ └── terraform.0-12-24.tfstate │ ├── nodejs │ │ ├── .gitignore │ │ ├── Pulumi.yaml │ │ ├── index.ts │ │ ├── package.json │ │ ├── terraform.0-12-24.tfstate │ │ └── tsconfig.json │ ├── python │ │ ├── .gitignore │ │ ├── Pulumi.yaml │ │ ├── __main__.py │ │ ├── requirements.txt │ │ └── terraform.0-12-24.tfstate │ └── yaml │ │ ├── Pulumi.yaml │ │ └── terraform.0-12-24.tfstate └── remote │ ├── go │ ├── Pulumi.yaml │ ├── go.mod │ ├── go.sum │ └── main.go │ └── yaml │ └── Pulumi.yaml ├── go.mod ├── go.sum ├── main.go ├── provider ├── log.go ├── provider.go ├── shim │ ├── go.mod │ ├── go.sum │ └── shim.go ├── state_reference │ ├── local.go │ ├── remote.go │ └── state_reference.go └── version │ └── version.go ├── schema.json └── sdk ├── .gitignore ├── dotnet ├── Provider.cs ├── Pulumi.Terraform.csproj ├── README.md ├── State │ ├── GetLocalReference.cs │ ├── GetRemoteReference.cs │ ├── Inputs │ │ ├── Workspaces.cs │ │ └── WorkspacesArgs.cs │ └── README.md ├── Utilities.cs ├── logo.png └── pulumi-plugin.json ├── go.mod ├── go.sum ├── go └── terraform │ ├── doc.go │ ├── init.go │ ├── internal │ ├── pulumiUtilities.go │ └── pulumiVersion.go │ ├── provider.go │ ├── pulumi-plugin.json │ └── state │ ├── getLocalReference.go │ ├── getRemoteReference.go │ └── pulumiTypes.go ├── java ├── README.md ├── settings.gradle └── src │ └── main │ └── java │ └── com │ └── pulumi │ └── terraform │ ├── Provider.java │ ├── ProviderArgs.java │ ├── Utilities.java │ └── state │ ├── StateFunctions.java │ ├── inputs │ ├── GetLocalReferenceArgs.java │ ├── GetLocalReferencePlainArgs.java │ ├── GetRemoteReferenceArgs.java │ ├── GetRemoteReferencePlainArgs.java │ ├── Workspaces.java │ └── WorkspacesArgs.java │ └── outputs │ ├── GetLocalReferenceResult.java │ └── GetRemoteReferenceResult.java ├── nodejs ├── README.md ├── index.ts ├── package.json ├── provider.ts ├── state │ ├── getLocalReference.ts │ ├── getRemoteReference.ts │ └── index.ts ├── tsconfig.json ├── types │ ├── index.ts │ ├── input.ts │ └── output.ts └── utilities.ts └── python ├── README.md ├── pulumi_terraform ├── README.md ├── __init__.py ├── _utilities.py ├── provider.py ├── pulumi-plugin.json ├── py.typed └── state │ ├── __init__.py │ ├── _inputs.py │ ├── get_local_reference.py │ └── get_remote_reference.py └── pyproject.toml /.ci-mgmt.yaml: -------------------------------------------------------------------------------- 1 | template: native 2 | provider: terraform 3 | major-version: 6 4 | pulumiVersionFile: .pulumi.version 5 | providerDefaultBranch: master 6 | parallel: 3 7 | envOverride: 8 | PULUMI_API: https://api.pulumi-staging.io 9 | TFE_ORGANIZATION: ${{ secrets.TFE_ORGANIZATION }} 10 | TFE_TOKEN: ${{ secrets.TFE_TOKEN }} 11 | -------------------------------------------------------------------------------- /.github/workflows/command-dispatch.yml: -------------------------------------------------------------------------------- 1 | # WARNING: This file is autogenerated - changes will be overwritten if not made via https://github.com/pulumi/ci-mgmt 2 | 3 | name: command-dispatch 4 | on: 5 | issue_comment: 6 | types: 7 | - created 8 | - edited 9 | env: 10 | GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} 11 | PROVIDER: terraform 12 | PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} 13 | PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget 14 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 15 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 16 | NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} 17 | PYPI_USERNAME: __token__ 18 | PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} 19 | TRAVIS_OS_NAME: linux 20 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 21 | PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/.. 22 | PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }} 23 | PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 24 | SIGNING_KEY_ID: ${{ secrets.JAVA_SIGNING_KEY_ID }} 25 | SIGNING_KEY: ${{ secrets.JAVA_SIGNING_KEY }} 26 | SIGNING_PASSWORD: ${{ secrets.JAVA_SIGNING_PASSWORD }} 27 | GOVERSION: "1.21.x" 28 | NODEVERSION: "20.x" 29 | PYTHONVERSION: "3.11.8" 30 | DOTNETVERSION: "8.0.x" 31 | JAVAVERSION: "11" 32 | PULUMI_API: https://api.pulumi-staging.io 33 | TFE_ORGANIZATION: ${{ secrets.TFE_ORGANIZATION }} 34 | TFE_TOKEN: ${{ secrets.TFE_TOKEN }} 35 | jobs: 36 | command-dispatch-for-testing: 37 | runs-on: ubuntu-latest 38 | name: command-dispatch-for-testing 39 | steps: 40 | - name: Checkout Repo 41 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 42 | with: 43 | lfs: true 44 | - uses: peter-evans/slash-command-dispatch@13bc09769d122a64f75aa5037256f6f2d78be8c4 # v4.0.0 45 | with: 46 | token: ${{ secrets.PULUMI_BOT_TOKEN }} 47 | reaction-token: ${{ secrets.GITHUB_TOKEN }} 48 | commands: run-acceptance-tests 49 | permission: write 50 | issue-type: pull-request 51 | repository: pulumi/pulumi-terraform 52 | if: ${{ github.event.issue.pull_request }} 53 | -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | # WARNING: This file is autogenerated - changes will be overwritten if not made via https://github.com/pulumi/ci-mgmt 2 | 3 | name: pull-request 4 | on: 5 | pull_request_target: {} 6 | env: 7 | GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} 8 | PROVIDER: terraform 9 | PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} 10 | PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget 11 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 12 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 13 | NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} 14 | PYPI_USERNAME: __token__ 15 | PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} 16 | TRAVIS_OS_NAME: linux 17 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 18 | PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/.. 19 | PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }} 20 | PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 21 | SIGNING_KEY_ID: ${{ secrets.JAVA_SIGNING_KEY_ID }} 22 | SIGNING_KEY: ${{ secrets.JAVA_SIGNING_KEY }} 23 | SIGNING_PASSWORD: ${{ secrets.JAVA_SIGNING_PASSWORD }} 24 | GOVERSION: "1.21.x" 25 | NODEVERSION: "20.x" 26 | PYTHONVERSION: "3.11.8" 27 | DOTNETVERSION: "8.0.x" 28 | JAVAVERSION: "11" 29 | PULUMI_API: https://api.pulumi-staging.io 30 | TFE_ORGANIZATION: ${{ secrets.TFE_ORGANIZATION }} 31 | TFE_TOKEN: ${{ secrets.TFE_TOKEN }} 32 | jobs: 33 | comment-on-pr: 34 | runs-on: ubuntu-latest 35 | name: comment-on-pr 36 | steps: 37 | - name: Checkout Repo 38 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 39 | with: 40 | lfs: true 41 | - name: Comment PR 42 | uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 43 | with: 44 | message: > 45 | PR is now waiting for a maintainer to run the acceptance tests. 46 | 47 | **Note for the maintainer:** To run the acceptance tests, please comment */run-acceptance-tests* on the PR 48 | github-token: ${{ secrets.GITHUB_TOKEN }} 49 | if: github.event.pull_request.head.repo.full_name != github.repository 50 | -------------------------------------------------------------------------------- /.github/workflows/weekly-pulumi-update.yml: -------------------------------------------------------------------------------- 1 | # WARNING: This file is autogenerated - changes will be overwritten if not made via https://github.com/pulumi/ci-mgmt 2 | 3 | name: weekly-pulumi-update 4 | on: 5 | schedule: 6 | - cron: 35 12 * * 4 7 | workflow_dispatch: {} 8 | env: 9 | GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} 10 | PROVIDER: terraform 11 | PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} 12 | PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget 13 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 14 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 15 | NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} 16 | PYPI_USERNAME: __token__ 17 | PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} 18 | TRAVIS_OS_NAME: linux 19 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 20 | PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/.. 21 | PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }} 22 | PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 23 | SIGNING_KEY_ID: ${{ secrets.JAVA_SIGNING_KEY_ID }} 24 | SIGNING_KEY: ${{ secrets.JAVA_SIGNING_KEY }} 25 | SIGNING_PASSWORD: ${{ secrets.JAVA_SIGNING_PASSWORD }} 26 | GOVERSION: "1.21.x" 27 | NODEVERSION: "20.x" 28 | PYTHONVERSION: "3.11.8" 29 | DOTNETVERSION: "8.0.x" 30 | JAVAVERSION: "11" 31 | PULUMI_API: https://api.pulumi-staging.io 32 | TFE_ORGANIZATION: ${{ secrets.TFE_ORGANIZATION }} 33 | TFE_TOKEN: ${{ secrets.TFE_TOKEN }} 34 | jobs: 35 | weekly-pulumi-update: 36 | runs-on: ubuntu-latest 37 | steps: 38 | - name: Checkout Repo 39 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 40 | with: 41 | lfs: true 42 | - name: Install Go 43 | uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 44 | with: 45 | go-version: ${{ env.GOVERSION }} 46 | cache-dependency-path: "**/*.sum" 47 | - name: Install pulumictl 48 | uses: jaxxstorm/action-install-gh-release@6096f2a2bbfee498ced520b6922ac2c06e990ed2 # v2.1.0 49 | with: 50 | repo: pulumi/pulumictl 51 | - name: Install Pulumi CLI 52 | uses: pulumi/actions@df5a93ad715135263c732ba288301bd044c383c0 # v6.3.0 53 | with: 54 | pulumi-version-file: .pulumi.version 55 | - name: Setup DotNet 56 | uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 57 | with: 58 | dotnet-version: ${{ env.DOTNETVERSION }} 59 | - name: Setup Node 60 | uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 61 | with: 62 | node-version: ${{ env.NODEVERSION }} 63 | registry-url: https://registry.npmjs.org 64 | - name: Setup Python 65 | uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 66 | with: 67 | python-version: ${{ env.PYTHONVERSION }} 68 | - name: Update Pulumi/Pulumi 69 | id: gomod 70 | run: >- 71 | git config --local user.email 'bot@pulumi.com' 72 | 73 | git config --local user.name 'pulumi-bot' 74 | 75 | git checkout -b update-pulumi/${{ github.run_id }}-${{ github.run_number }} 76 | 77 | for MODFILE in $(find . -name go.mod); do pushd $(dirname $MODFILE); go get github.com/pulumi/pulumi/pkg/v3 github.com/pulumi/pulumi/sdk/v3; go mod tidy; popd; done 78 | 79 | gh repo view pulumi/pulumi --json latestRelease --jq .latestRelease.tagName | sed 's/^v//' > .pulumi.version 80 | 81 | git update-index -q --refresh 82 | 83 | if ! git diff-files --quiet; then echo changes=1 >> "$GITHUB_OUTPUT"; fi 84 | - name: Provider with Pulumi Upgrade 85 | if: steps.gomod.outputs.changes != 0 86 | run: >- 87 | make codegen && make local_generate 88 | 89 | git add sdk/nodejs 90 | 91 | git commit -m "Regenerating Node.js SDK based on updated modules" || echo "ignore commit failure, may be empty" 92 | 93 | git add sdk/python 94 | 95 | git commit -m "Regenerating Python SDK based on updated modules" || echo "ignore commit failure, may be empty" 96 | 97 | git add sdk/dotnet 98 | 99 | git commit -m "Regenerating .NET SDK based on updated modules" || echo "ignore commit failure, may be empty" 100 | 101 | git add sdk/go* 102 | 103 | git commit -m "Regenerating Go SDK based on updated modules" || echo "ignore commit failure, may be empty" 104 | 105 | git add sdk/java* 106 | 107 | git commit -m "Regenerating Java SDK based on updated modules" || echo "ignore commit failure, may be empty" 108 | 109 | git add . 110 | 111 | git commit -m "Updated modules" || echo "ignore commit failure, may be empty" 112 | 113 | git push origin update-pulumi/${{ github.run_id }}-${{ github.run_number }} 114 | - name: Create PR 115 | id: create-pr 116 | if: steps.gomod.outputs.changes != 0 117 | run: > 118 | ver=$(cat .pulumi.version) 119 | 120 | msg="Automated upgrade: bump pulumi/pulumi to ${ver}" 121 | 122 | # See https://github.com/cli/cli/issues/6485#issuecomment-2560935183 for --head workaround 123 | 124 | gh pr create -t "$msg" -b "$msg" --head $(git branch --show-current) 125 | env: 126 | GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} 127 | name: weekly-pulumi-update 128 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .code 3 | **/vendor/ 4 | .pulumi 5 | **/bin/ 6 | **/obj/ 7 | Pulumi.*.yaml 8 | **/node_modules/ 9 | .DS_Store 10 | 11 | **/command-output/ 12 | 13 | .idea/ 14 | *.iml 15 | 16 | yarn.lock 17 | **/pulumiManifest.go 18 | 19 | ci-scripts 20 | **/schema.go 21 | **/version.txt 22 | **/nuget 23 | **/maven 24 | **/dist 25 | .make 26 | sdk/java/build 27 | sdk/java/.gradle 28 | sdk/java/build.gradle 29 | sdk/python/venv 30 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | timeout: 10m 3 | # Enable checking the by default skipped "examples" dirs 4 | build-tags: 5 | - all 6 | linters: 7 | enable-all: false 8 | enable: 9 | - durationcheck 10 | - errcheck 11 | - exhaustive 12 | - gofumpt 13 | - goheader 14 | - goprintffuncname 15 | - gosec 16 | - govet 17 | - importas 18 | - ineffassign 19 | - lll 20 | - misspell 21 | - nakedret 22 | - nolintlint 23 | - paralleltest 24 | - perfsprint 25 | - prealloc 26 | - revive 27 | - unconvert 28 | - unused 29 | - usetesting 30 | - wastedassign 31 | - whitespace 32 | 33 | linters-settings: 34 | nakedret: 35 | # Make an issue if func has more lines of code than this setting, and it has naked returns. 36 | # Default: 30 37 | max-func-lines: 60 38 | govet: 39 | enable: 40 | - nilness 41 | # Reject comparisons of reflect.Value with DeepEqual or '=='. 42 | - reflectvaluecompare 43 | # Reject sort.Slice calls with a non-slice argument. 44 | - sortslice 45 | # Detect write to struct/arrays by-value that aren't read again. 46 | - unusedwrite 47 | goheader: 48 | values: 49 | regexp: 50 | COPYRIGHT_YEARS: (\d{4}-)?\d{4} 51 | WHITESPACE: \s* 52 | template: |- 53 | Copyright {{ COPYRIGHT_YEARS }}, Pulumi Corporation. 54 | 55 | Licensed under the Apache License, Version 2.0 (the "License"); 56 | you may not use this file except in compliance with the License. 57 | You may obtain a copy of the License at 58 | 59 | {{ WHITESPACE }}http://www.apache.org/licenses/LICENSE-2.0 60 | 61 | Unless required by applicable law or agreed to in writing, software 62 | distributed under the License is distributed on an "AS IS" BASIS, 63 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 64 | See the License for the specific language governing permissions and 65 | limitations under the License. 66 | 67 | issues: 68 | exclude-rules: 69 | # staticcheck already has smarter checks for empty blocks. 70 | # revive's empty-block linter has false positives. 71 | # For example, as of writing this, the following is not allowed. 72 | # for foo() { } 73 | - linters: [revive] 74 | text: 'empty-block: this block is empty, you can remove it' 75 | 76 | exclude-dirs: 77 | - sdk 78 | exclude-dirs-use-default: false 79 | -------------------------------------------------------------------------------- /.goreleaser.prerelease.yml: -------------------------------------------------------------------------------- 1 | # WARNING: This file is autogenerated - changes will be overwritten if not made via https://github.com/pulumi/ci-mgmt 2 | 3 | project_name: pulumi-terraform 4 | builds: 5 | - id: build-provider 6 | env: 7 | - CGO_ENABLED=0 8 | - GO111MODULE=on 9 | goos: 10 | - darwin 11 | - linux 12 | goarch: 13 | - amd64 14 | - arm64 15 | ignore: &a1 [] 16 | ldflags: &a2 17 | - -s 18 | - -w 19 | - -X 20 | github.com/pulumi/pulumi-terraform/v6/provider/version.version={{.Tag}} 21 | binary: pulumi-resource-terraform 22 | - id: build-provider-sign-windows 23 | env: 24 | - CGO_ENABLED=0 25 | - GO111MODULE=on 26 | goos: 27 | - windows 28 | goarch: 29 | - amd64 30 | - arm64 31 | ignore: *a1 32 | ldflags: *a2 33 | binary: pulumi-resource-terraform 34 | hooks: 35 | post: 36 | - make sign-goreleaser-exe-{{ .Arch }} 37 | archives: 38 | - name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" 39 | id: archive 40 | snapshot: 41 | name_template: "{{ .Tag }}-SNAPSHOT" 42 | changelog: 43 | skip: true 44 | release: 45 | disable: true 46 | blobs: 47 | - provider: s3 48 | region: us-west-2 49 | bucket: get.pulumi.com 50 | folder: releases/plugins/ 51 | ids: 52 | - archive 53 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # WARNING: This file is autogenerated - changes will be overwritten if not made via https://github.com/pulumi/ci-mgmt 2 | 3 | project_name: pulumi-terraform 4 | builds: 5 | - id: build-provider 6 | env: 7 | - CGO_ENABLED=0 8 | - GO111MODULE=on 9 | goos: 10 | - darwin 11 | - linux 12 | goarch: 13 | - amd64 14 | - arm64 15 | ignore: &a1 [] 16 | ldflags: &a2 17 | - -s 18 | - -w 19 | - -X 20 | github.com/pulumi/pulumi-terraform/v6/provider/version.version={{.Tag}} 21 | binary: pulumi-resource-terraform 22 | - id: build-provider-sign-windows 23 | env: 24 | - CGO_ENABLED=0 25 | - GO111MODULE=on 26 | goos: 27 | - windows 28 | goarch: 29 | - amd64 30 | - arm64 31 | ignore: *a1 32 | ldflags: *a2 33 | binary: pulumi-resource-terraform 34 | hooks: 35 | post: 36 | - make sign-goreleaser-exe-{{ .Arch }} 37 | archives: 38 | - name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" 39 | id: archive 40 | snapshot: 41 | name_template: "{{ .Tag }}-SNAPSHOT" 42 | changelog: 43 | skip: true 44 | release: 45 | disable: false 46 | blobs: 47 | - provider: s3 48 | region: us-west-2 49 | bucket: get.pulumi.com 50 | folder: releases/plugins/ 51 | ids: 52 | - archive 53 | -------------------------------------------------------------------------------- /.pulumi.version: -------------------------------------------------------------------------------- 1 | v3.160.0 -------------------------------------------------------------------------------- /CHANGELOG_OLD.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | ## Notice (2022-01-06) 5 | 6 | *As of this notice, using CHANGELOG.md is DEPRECATED. We will be using [GitHub Releases](https://github.com/pulumi/pulumi-terraform/releases) for this repository* 7 | 8 | ## HEAD (Unreleased) 9 | _(none)_ 10 | 11 | --- 12 | 13 | ## 5.5.1 (2021-12-20) 14 | * Upgrade to Terraform v1.1.2 15 | 16 | ## 5.5.0 (2021-12-10) 17 | * Upgrade to Terraform v1.1.0 18 | 19 | ## 5.4.3 (2021-11-18) 20 | * Upgrade to Terraform v1.0.11 21 | 22 | ## 5.4.2 (2021-11-01) 23 | * Upgrade to Terraform v1.0.10 24 | 25 | ## 5.4.1 (2021-10-04) 26 | * Upgrade to Terraform v1.0.8 27 | 28 | ## 5.4.0 (2021-09-27) 29 | * Upgrade to Terraform v1.0.7 30 | 31 | ## 5.3.0 (2021-09-09) 32 | * Upgrade to Terraform v1.0.6 33 | 34 | ## 5.2.1 (2021-08-17) 35 | * Add support for S3-style supported backends to the S3 Backend 36 | 37 | ## 5.2.0 (2021-05-12) 38 | * Upgrade to Terraform v0.15.3 39 | 40 | ## 5.1.0 (2021-04-30) 41 | * Upgrade to Terraform v0.15.1 42 | 43 | ## 5.0.0 (2021-04-26) 44 | * Upgrade to Terraform v0.15.0 45 | * Upgrade to Pulumi v3.0 46 | **Please Note:** This upgrade to Pulumi v3 means that we have introduced a major version bump in the provider 47 | 48 | ## 4.7.0 (2021-04-12) 49 | * Upgrade to Terraform v0.14.10 50 | 51 | ## 4.6.0 (2021-03-30) 52 | * Upgrade to Terraform v0.14.9 53 | 54 | ## 4.5.0 (2021-02-25) 55 | * Upgrade to Terraform v0.14.7 56 | * Add support for AliCloud OSS Backend type 57 | 58 | ## 4.4.0 (2021-02-08) 59 | * Upgrade to Terraform v0.14.6 60 | 61 | ## 4.3.0 (2021-01-21) 62 | * Upgrade to Terraform v0.14.5 63 | 64 | ## 4.2.0 (2021-01-08) 65 | * Upgrade to Terraform v0.14.4 66 | 67 | ## 4.1.0 (2020-12-22) 68 | * Upgrade to Terraform v0.14.3 69 | 70 | ## 4.0.0 (2020-12-07) 71 | * Upgrade to Terraform v0.14.0 72 | 73 | ## 3.4.0 (2020-10-26) 74 | * Upgrade to Pulumi v2.12.0 75 | * Upgrade to Terraform v0.13.5 76 | 77 | ## 3.3.0 (2020-10-01) 78 | * Upgrade to Terraform v0.13.4 79 | 80 | ## 3.2.0 (2020-09-19) 81 | * Upgrade to Terraform v0.13.2 82 | * Upgrade to Pulumi v2.10.1 83 | 84 | ## 3.1.0 (2020-09-02) 85 | * Upgrade to Terraform v0.13.2 86 | 87 | ## 3.0.0 (2020-08-28) 88 | * Upgrade to Terraform v0.13.1 89 | * Upgrade to Pulumi v2.9.1 90 | 91 | ## 2.5.0 (2020-08-10) 92 | * Upgrade to Terraform v0.12.29 93 | 94 | ## 2.4.0 (2020-06-26) 95 | * Upgrade to Terraform v0.12.28 96 | 97 | ## 2.3.0 (2020-05-27) 98 | * Upgrade to Terraform v0.12.26 99 | 100 | ## 2.2.0 (2020-05-19) 101 | * Upgrade to Terraform v0.12.25 102 | 103 | ## 2.1.0 (2020-05-15) 104 | * Add support for Go with the `pulumi-terraform` Go SDK 105 | 106 | ## v2.0.0 (2020-05-02) 107 | * `RemoteStateReference` resources can now read states created with Terraform v0.12.24 and below 108 | * Fix a bug with `RemoteStateReference`'s remote state backend on Python, where the workspace name was not getting configured correctly (issue [#524](https://github.com/pulumi/pulumi-terraform/issues/524)). 109 | * Added support for .NET with the `Pulumi.Terraform` NuGet package 110 | 111 | ## v1.1.0 (2019-10-04) 112 | * Upgrade the Pulumi dependency requirements for NodeJS and Python SDKs 113 | 114 | ## v1.0.0 (2019-10-02) 115 | * Use of the `RemoteStateReference` resource no longer results in a panic if the configured remote state cannot be accessed 116 | * `RemoteStateReference` resources can now read states created with Terraform v0.12.9 and below 117 | * Added support for Python with the `pulumi_terraform` package 118 | 119 | ## v0.18.1 (2019-05-16) 120 | * Initial release of `@pulumi/terraform` with support for Node.js. 121 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | education, socio-economic status, nationality, personal appearance, race, 10 | religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | * Contribute in a positive and constructive way 23 | 24 | Examples of unacceptable behavior by participants include: 25 | 26 | * The use of sexualized language or imagery and unwelcome sexual attention or 27 | advances 28 | * Trolling, insulting/derogatory comments, and personal or political attacks 29 | * Public or private harassment 30 | * Publishing others' private information, such as a physical or electronic 31 | address, without explicit permission 32 | * Other conduct which could reasonably be considered inappropriate in a 33 | professional setting 34 | 35 | ## Our Community Guidelines 36 | * Be clear and stay on topic. Communicating with strangers on the Internet can make it hard to convey or read tone, and sarcasm is frequently misunderstood. Try to use clear language, and think about how the other person will receive it. 37 | * Don’t cross-post the same thing in multiple GitHub Discussion topics or multiple Slack channels. This can make it difficult for people answering your questions and creates "scrollback spam". 38 | * Public discussion is preferred to private. Avoid using Slack DMs for questions, and instead share them in public Slack channels or GitHub Discussion threads. This allows a larger audience to both share their knowledge as well as learn from your question or issue. If you're having a problem, chances are someone else is having a similar problem. Learning in public is a community contribution. 39 | * Minimize notifications to other community members. Avoid tagging other community members in Slack messages or Discussion threads, unless you are replying to something specific. Community members are here to help each other, but are not "on call" for support, and we expect everyone to try to minimize "notification fatigue". If your issue is time-sensitive or critical, use methods like support@pulumi.com instead. 40 | 41 | ## Our Responsibilities 42 | 43 | Project maintainers are responsible for clarifying the standards of acceptable 44 | behavior and are expected to take appropriate and fair corrective action in 45 | response to any instances of unacceptable behavior. 46 | 47 | Project maintainers have the right and responsibility to remove, edit, or 48 | reject comments, commits, code, wiki edits, issues, GitHub Discussions posts, 49 | and other contributions that are not aligned to this Code of Conduct, or to ban 50 | temporarily or permanently any contributor for other behaviors that they deem 51 | inappropriate, threatening, offensive, or harmful. 52 | 53 | ## Scope 54 | 55 | This Code of Conduct applies both within project spaces (including the Community Slack 56 | and GitHub Discussions forums) and in public spaces when an individual is representing the 57 | project or its community. Examples of representing a project or community include 58 | using an official project e-mail address, posting via an official social media account, 59 | or acting as an appointed representative at an online or offline event. Representation 60 | of a project may be further defined and clarified by project maintainers. 61 | 62 | ## Enforcement 63 | 64 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 65 | reported by contacting the project team at code-of-conduct@pulumi.com. All 66 | complaints will be reviewed and investigated and will result in a response that 67 | is deemed necessary and appropriate to the circumstances. The project team is 68 | obligated to maintain confidentiality with regard to the reporter of an incident. 69 | Further details of specific enforcement policies may be posted separately. 70 | 71 | Project maintainers who do not follow or enforce the Code of Conduct in good 72 | faith may face temporary or permanent repercussions as determined by other 73 | members of the project's leadership. 74 | 75 | ## Attribution 76 | 77 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 78 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 79 | 80 | [homepage]: https://www.contributor-covenant.org 81 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Pulumi 2 | 3 | Do you want to hack on Pulumi? Awesome! We are so happy to have you. 4 | 5 | Please refer to the [Pulumi documentation repo][docsrepo]'s [CONTRIBUTING.md file][contributing] for details on how to do so. 6 | 7 | 8 | [docsrepo]: https://github.com/pulumi/docs/ 9 | [contributing]: https://github.com/pulumi/docs/blob/master/CONTRIBUTING.md 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pulumi Terraform Provider 2 | 3 | The Terraform resource provider for Pulumi lets you consume the outputs contained in 4 | Terraform state files from your Pulumi programs. 5 | 6 | > [!IMPORTANT] 7 | > For reference docs and installation instructions, please go to 8 | > . 9 | -------------------------------------------------------------------------------- /docs/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Terraform 3 | meta_desc: Consume Terraform state in Pulumi 4 | layout: package 5 | --- 6 | 7 | The Terraform provider allows you to reference Terraform state from Pulumi programs. 8 | 9 | 10 | ## Example 11 | 12 | {{< chooser language "typescript,python,go,csharp,java,yaml" >}} 13 | 14 | {{% choosable language typescript %}} 15 | 16 | ```typescript 17 | import { state as tf_state } from "@pulumi/terraform"; 18 | 19 | let outputs = tf_state.getLocalReferenceOutput({ 20 | path: "./terraform.0-12-24.tfstate", 21 | }); 22 | 23 | export const state = outputs.outputs; 24 | ``` 25 | 26 | {{% /choosable %}} 27 | 28 | {{% choosable language python %}} 29 | 30 | ```python 31 | import pulumi 32 | import pulumi_terraform as terraform 33 | 34 | outputs = terraform.state.get_local_reference(path="./terraform.0-12-24.tfstate") 35 | 36 | pulumi.export("state", outputs.outputs) 37 | ``` 38 | 39 | {{% /choosable %}} 40 | 41 | {{% choosable language go %}} 42 | 43 | ```go 44 | package main 45 | 46 | import ( 47 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/state" 48 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 49 | ) 50 | 51 | func main() { 52 | pulumi.Run(func(ctx *pulumi.Context) error { 53 | state := state.GetLocalReferenceOutput(ctx, state.GetLocalReferenceOutputArgs{ 54 | Path: pulumi.String("./terraform.0-12-24.tfstate"), 55 | }) 56 | ctx.Export("state", state.Outputs()) 57 | return nil 58 | }) 59 | } 60 | ``` 61 | 62 | {{% /choosable %}} 63 | 64 | {{% choosable language csharp %}} 65 | 66 | ```csharp 67 | using System.Collections.Generic; 68 | using Pulumi; 69 | using Pulumi.Terraform.State; 70 | 71 | return await Deployment.RunAsync(() => 72 | { 73 | var outputs = GetLocalReference.Invoke(new GetLocalReferenceInvokeArgs 74 | { 75 | Path = "./terraform.0-12-24.tfstate", 76 | }); 77 | 78 | return new Dictionary 79 | { 80 | ["state"] = outputs.Apply(x => x.Outputs), 81 | }; 82 | }); 83 | ``` 84 | 85 | {{% /choosable %}} 86 | 87 | {{% choosable language java %}} 88 | 89 | ```java 90 | package myproject; 91 | 92 | import com.pulumi.Pulumi; 93 | import com.pulumi.core.Output; 94 | import com.pulumi.terraform.state.StateFunctions; 95 | import com.pulumi.terraform.state.inputs.GetLocalReferenceArgs; 96 | 97 | public class App { 98 | public static void main(String[] args) { 99 | Pulumi.run(ctx -> { 100 | var output = StateFunctions.getLocalReference(GetLocalReferenceArgs.builder().path("./terraform.0-12-24.tfstate").build()); 101 | ctx.export("state", output.applyValue(x -> x.outputs())); 102 | }); 103 | } 104 | } 105 | ``` 106 | 107 | {{% /choosable %}} 108 | 109 | {{% choosable language yaml %}} 110 | 111 | ```yaml 112 | name: terraform-local-state-with-yaml 113 | runtime: yaml 114 | outputs: 115 | state: 116 | fn::invoke: 117 | function: terraform:state:getLocalReference 118 | arguments: 119 | path: ./terraform.0-12-24.tfstate 120 | return: outputs 121 | ``` 122 | 123 | {{% /choosable %}} 124 | 125 | {{< /chooser >}} 126 | -------------------------------------------------------------------------------- /examples/examples_dotnet_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. All rights reserved. 2 | //go:build dotnet || all 3 | // +build dotnet all 4 | 5 | package examples 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestDotnet(t *testing.T) { 12 | t.Parallel() 13 | LanguageTests(t, "dotnet") 14 | } 15 | -------------------------------------------------------------------------------- /examples/examples_go_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. All rights reserved. 2 | //go:build go || all 3 | // +build go all 4 | 5 | package examples 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestGo(t *testing.T) { 12 | t.Parallel() 13 | LanguageTests(t, "go") 14 | } 15 | -------------------------------------------------------------------------------- /examples/examples_java_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. All rights reserved. 2 | //go:build java || all 3 | // +build java all 4 | 5 | package examples 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestJava(t *testing.T) { 12 | t.Parallel() 13 | LanguageTests(t, "java") 14 | } 15 | -------------------------------------------------------------------------------- /examples/examples_nodejs_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. All rights reserved. 2 | //go:build nodejs || all 3 | // +build nodejs all 4 | 5 | package examples 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestNodejs(t *testing.T) { 12 | t.Parallel() 13 | LanguageTests(t, "nodejs") 14 | } 15 | -------------------------------------------------------------------------------- /examples/examples_python_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. All rights reserved. 2 | //go:build python || all 3 | // +build python all 4 | 5 | package examples 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestPython(t *testing.T) { 12 | t.Parallel() 13 | LanguageTests(t, "python") 14 | } 15 | -------------------------------------------------------------------------------- /examples/examples_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples 16 | 17 | import ( 18 | "errors" 19 | "os" 20 | "path/filepath" 21 | "testing" 22 | 23 | "github.com/pulumi/pulumi/pkg/v3/testing/integration" 24 | "github.com/stretchr/testify/assert" 25 | "github.com/stretchr/testify/require" 26 | ) 27 | 28 | func getRemoteBackendOrganization(t *testing.T) string { 29 | org, found := os.LookupEnv("TFE_ORGANIZATION") 30 | if !found { 31 | t.Skipf("Skipping... cannot find TFE_ORGANIZATION") 32 | } 33 | 34 | return org 35 | } 36 | 37 | func getRemoteBackendToken(t *testing.T) string { 38 | token, found := os.LookupEnv("TFE_TOKEN") 39 | if !found { 40 | t.Skipf("Skipping... cannot find TFE_TOKEN") 41 | } 42 | 43 | return token 44 | } 45 | 46 | func getwd(t *testing.T) string { 47 | s, err := os.Getwd() 48 | require.NoError(t, err) 49 | return s 50 | } 51 | 52 | func getDependencies(t *testing.T, language string) []string { 53 | switch language { 54 | case "go": 55 | return []string{"github.com/pulumi/pulumi-terraform/sdk/v6=" + getwd(t) + "/../sdk"} 56 | case "nodejs": 57 | return []string{"@pulumi/terraform"} 58 | case "python": 59 | return []string{"../sdk/python"} 60 | case "dotnet": 61 | return []string{"Pulumi.Terraform"} 62 | default: 63 | return nil 64 | } 65 | } 66 | 67 | func TestMain(m *testing.M) { 68 | set := func(envVar, path string) error { 69 | abs, err := filepath.Abs(path) 70 | if err != nil { 71 | return err 72 | } 73 | return os.Setenv(envVar, abs) 74 | } 75 | 76 | err := errors.Join( 77 | set("PULUMI_LOCAL_NUGET", "../nuget"), 78 | set("PULUMI_LOCAL_MAVEN", "../maven"), 79 | ) 80 | if err != nil { 81 | panic(err) 82 | } 83 | os.Exit(m.Run()) 84 | } 85 | 86 | func LanguageTests(t *testing.T, language string) { 87 | type languageTest struct { 88 | doesNotNeedConfig bool 89 | expectedStackOutputs map[string]any 90 | } 91 | tests := map[string]languageTest{ 92 | "local": { 93 | doesNotNeedConfig: true, 94 | expectedStackOutputs: map[string]any{ 95 | "state": map[string]any{ 96 | "bucket_arn": "arn:aws:s3:::hello-world-abc12345", 97 | "public_subnet_ids": []any{ 98 | "subnet-023a5a6867d194162", 99 | "subnet-0eea17cb6af21b5e5", 100 | "subnet-02822dcd2e06634cf", 101 | }, 102 | "vpc_id": "vpc-0d9ff66ccda7c9765", 103 | }, 104 | "bucketArn": "arn:aws:s3:::hello-world-abc12345", 105 | "firstSubnetId": "subnet-023a5a6867d194162", 106 | }, 107 | }, 108 | "remote": { 109 | expectedStackOutputs: map[string]any{ 110 | "state": map[string]any{ 111 | "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270", 112 | "plaintext": "{\"password\":\"EOZcr9x4V@ep8T1gjmR4RJ39aT9vQDsDwZx\"}", 113 | }, 114 | }, 115 | }, 116 | } 117 | 118 | examplesDir := "." 119 | examples, err := os.ReadDir(examplesDir) 120 | require.NoError(t, err) 121 | 122 | for _, dir := range examples { 123 | if !dir.IsDir() { 124 | continue 125 | } 126 | 127 | testDir := filepath.Join(examplesDir, dir.Name(), language) 128 | _, err := os.Stat(testDir) 129 | if os.IsNotExist(err) { 130 | continue 131 | } 132 | require.NoError(t, err) 133 | 134 | // We have found a yaml example called dir.Name, so we should run it async. 135 | t.Run(dir.Name(), func(t *testing.T) { 136 | test := tests[dir.Name()] 137 | var config map[string]string 138 | if !test.doesNotNeedConfig { 139 | config = map[string]string{ 140 | "remote_tf_token": getRemoteBackendToken(t), 141 | "remote_tf_org": getRemoteBackendOrganization(t), 142 | } 143 | } 144 | opts := integration.ProgramTestOptions{ 145 | Dir: testDir, 146 | DecryptSecretsInOutput: true, 147 | Config: config, 148 | LocalProviders: []integration.LocalDependency{{ 149 | Package: "terraform", 150 | Path: "../bin", 151 | }}, 152 | Dependencies: getDependencies(t, language), 153 | ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) { 154 | assert.Equal(t, test.expectedStackOutputs, stack.Outputs) 155 | }, 156 | } 157 | integration.ProgramTest(t, &opts) 158 | }) 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /examples/examples_yaml_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. All rights reserved. 2 | //go:build yaml || all 3 | // +build yaml all 4 | 5 | package examples 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestYAML(t *testing.T) { 12 | t.Parallel() 13 | LanguageTests(t, "yaml") 14 | } 15 | -------------------------------------------------------------------------------- /examples/local/dotnet/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Pulumi; 3 | using Pulumi.Terraform.State; 4 | 5 | return await Deployment.RunAsync(() => 6 | { 7 | var outputs = GetLocalReference.Invoke(new GetLocalReferenceInvokeArgs 8 | { 9 | Path = "./terraform.0-12-24.tfstate", 10 | }).Apply(x => x.Outputs); 11 | 12 | // Export outputs here 13 | return new Dictionary 14 | { 15 | ["state"] = outputs, 16 | ["bucketArn"] = outputs.Apply(x => x["bucket_arn"]), 17 | ["firstSubnetId"] = outputs.Apply(x => (x["public_subnet_ids"] as IList)[0]), 18 | }; 19 | }); 20 | -------------------------------------------------------------------------------- /examples/local/dotnet/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: dotnet 2 | description: A minimal C# Pulumi program 3 | runtime: dotnet 4 | -------------------------------------------------------------------------------- /examples/local/dotnet/dotnet.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/local/go/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: terraform-local-state-with-go 2 | description: Show how to use Pulumi's Terraform provider to read Terraform state in Go. 3 | runtime: go 4 | -------------------------------------------------------------------------------- /examples/local/go/go.mod: -------------------------------------------------------------------------------- 1 | module terraform-local-state-with-go 2 | 3 | go 1.22 4 | 5 | toolchain go1.24.1 6 | 7 | replace github.com/pulumi/pulumi-terraform/sdk/v6 => ../../../sdk 8 | 9 | require ( 10 | github.com/pulumi/pulumi-terraform/sdk/v6 v6.0.0-00010101000000-000000000000 11 | github.com/pulumi/pulumi/sdk/v3 v3.160.0 12 | ) 13 | 14 | require ( 15 | dario.cat/mergo v1.0.0 // indirect 16 | github.com/BurntSushi/toml v1.2.1 // indirect 17 | github.com/Microsoft/go-winio v0.6.1 // indirect 18 | github.com/ProtonMail/go-crypto v1.1.3 // indirect 19 | github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect 20 | github.com/agext/levenshtein v1.2.3 // indirect 21 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect 22 | github.com/atotto/clipboard v0.1.4 // indirect 23 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 24 | github.com/blang/semver v3.5.1+incompatible // indirect 25 | github.com/charmbracelet/bubbles v0.16.1 // indirect 26 | github.com/charmbracelet/bubbletea v0.25.0 // indirect 27 | github.com/charmbracelet/lipgloss v0.7.1 // indirect 28 | github.com/cheggaaa/pb v1.0.29 // indirect 29 | github.com/cloudflare/circl v1.3.7 // indirect 30 | github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect 31 | github.com/cyphar/filepath-securejoin v0.3.6 // indirect 32 | github.com/djherbis/times v1.5.0 // indirect 33 | github.com/emirpasic/gods v1.18.1 // indirect 34 | github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect 35 | github.com/go-git/go-billy/v5 v5.6.1 // indirect 36 | github.com/go-git/go-git/v5 v5.13.1 // indirect 37 | github.com/gogo/protobuf v1.3.2 // indirect 38 | github.com/golang/glog v1.2.4 // indirect 39 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 40 | github.com/google/uuid v1.6.0 // indirect 41 | github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect 42 | github.com/hashicorp/errwrap v1.1.0 // indirect 43 | github.com/hashicorp/go-multierror v1.1.1 // indirect 44 | github.com/hashicorp/hcl/v2 v2.17.0 // indirect 45 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 46 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect 47 | github.com/kevinburke/ssh_config v1.2.0 // indirect 48 | github.com/lucasb-eyer/go-colorful v1.2.0 // indirect 49 | github.com/mattn/go-isatty v0.0.19 // indirect 50 | github.com/mattn/go-localereader v0.0.1 // indirect 51 | github.com/mattn/go-runewidth v0.0.15 // indirect 52 | github.com/mitchellh/go-ps v1.0.0 // indirect 53 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect 54 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect 55 | github.com/muesli/cancelreader v0.2.2 // indirect 56 | github.com/muesli/reflow v0.3.0 // indirect 57 | github.com/muesli/termenv v0.15.2 // indirect 58 | github.com/opentracing/basictracer-go v1.1.0 // indirect 59 | github.com/opentracing/opentracing-go v1.2.0 // indirect 60 | github.com/pgavlin/fx v0.1.6 // indirect 61 | github.com/pjbgf/sha1cd v0.3.0 // indirect 62 | github.com/pkg/errors v0.9.1 // indirect 63 | github.com/pkg/term v1.1.0 // indirect 64 | github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect 65 | github.com/pulumi/esc v0.9.1 // indirect 66 | github.com/rivo/uniseg v0.4.4 // indirect 67 | github.com/rogpeppe/go-internal v1.12.0 // indirect 68 | github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect 69 | github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect 70 | github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect 71 | github.com/skeema/knownhosts v1.3.0 // indirect 72 | github.com/spf13/cobra v1.7.0 // indirect 73 | github.com/spf13/pflag v1.0.5 // indirect 74 | github.com/texttheater/golang-levenshtein v1.0.1 // indirect 75 | github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect 76 | github.com/uber/jaeger-lib v2.4.1+incompatible // indirect 77 | github.com/xanzy/ssh-agent v0.3.3 // indirect 78 | github.com/zclconf/go-cty v1.13.2 // indirect 79 | go.uber.org/atomic v1.9.0 // indirect 80 | golang.org/x/crypto v0.33.0 // indirect 81 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect 82 | golang.org/x/mod v0.19.0 // indirect 83 | golang.org/x/net v0.35.0 // indirect 84 | golang.org/x/sync v0.11.0 // indirect 85 | golang.org/x/sys v0.30.0 // indirect 86 | golang.org/x/term v0.29.0 // indirect 87 | golang.org/x/text v0.22.0 // indirect 88 | golang.org/x/tools v0.23.0 // indirect 89 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect 90 | google.golang.org/grpc v1.63.2 // indirect 91 | google.golang.org/protobuf v1.33.0 // indirect 92 | gopkg.in/warnings.v0 v0.1.2 // indirect 93 | gopkg.in/yaml.v3 v3.0.1 // indirect 94 | lukechampine.com/frand v1.4.2 // indirect 95 | ) 96 | -------------------------------------------------------------------------------- /examples/local/go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/state" 5 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 6 | ) 7 | 8 | func main() { 9 | pulumi.Run(func(ctx *pulumi.Context) error { 10 | state := state.GetLocalReferenceOutput(ctx, state.GetLocalReferenceOutputArgs{ 11 | Path: pulumi.String("./terraform.0-12-24.tfstate"), 12 | }).Outputs() 13 | ctx.Export("state", state) 14 | ctx.Export("bucketArn", state.MapIndex(pulumi.String("bucket_arn"))) 15 | ctx.Export("firstSubnetId", state.ApplyT(func(m map[string]any) string { 16 | return m["public_subnet_ids"].([]any)[0].(string) 17 | })) 18 | return nil 19 | }) 20 | } 21 | -------------------------------------------------------------------------------- /examples/local/go/terraform.0-12-24.tfstate: -------------------------------------------------------------------------------- 1 | { 2 | "version": 4, 3 | "terraform_version": "0.12.24", 4 | "serial": 18, 5 | "lineage": "9c01ca69-aabb-5a92-7f05-60f06607052c", 6 | "outputs": { 7 | "bucket_arn": { 8 | "value": "arn:aws:s3:::hello-world-abc12345", 9 | "type": "string" 10 | }, 11 | "public_subnet_ids": { 12 | "value": [ 13 | "subnet-023a5a6867d194162", 14 | "subnet-0eea17cb6af21b5e5", 15 | "subnet-02822dcd2e06634cf" 16 | ], 17 | "type": [ 18 | "tuple", 19 | [ 20 | "string", 21 | "string", 22 | "string" 23 | ] 24 | ] 25 | }, 26 | "vpc_id": { 27 | "value": "vpc-0d9ff66ccda7c9765", 28 | "type": "string" 29 | } 30 | }, 31 | "resources": [ 32 | { 33 | "mode": "managed", 34 | "type": "aws_s3_bucket", 35 | "name": "bucket", 36 | "provider": "provider.aws", 37 | "instances": [ 38 | { 39 | "schema_version": 0, 40 | "attributes": { 41 | "acceleration_status": "", 42 | "acl": "private", 43 | "arn": "arn:aws:s3:::hello-world-abc12345", 44 | "bucket": "hello-world-abc12345", 45 | "bucket_domain_name": "hello-world-abc12345.s3.amazonaws.com", 46 | "bucket_prefix": null, 47 | "bucket_regional_domain_name": "hello-world-abc12345.s3.us-west-2.amazonaws.com", 48 | "cors_rule": [], 49 | "force_destroy": false, 50 | "grant": [], 51 | "hosted_zone_id": "Z3BJ6K6RIION7M", 52 | "id": "hello-world-abc12345", 53 | "lifecycle_rule": [], 54 | "logging": [], 55 | "object_lock_configuration": [], 56 | "policy": null, 57 | "region": "us-west-2", 58 | "replication_configuration": [], 59 | "request_payer": "BucketOwner", 60 | "server_side_encryption_configuration": [], 61 | "tags": null, 62 | "versioning": [ 63 | { 64 | "enabled": false, 65 | "mfa_delete": false 66 | } 67 | ], 68 | "website": [], 69 | "website_domain": null, 70 | "website_endpoint": null 71 | }, 72 | "private": "bnVsbA==" 73 | } 74 | ] 75 | }, 76 | { 77 | "mode": "managed", 78 | "type": "aws_subnet", 79 | "name": "public", 80 | "each": "list", 81 | "provider": "provider.aws", 82 | "instances": [ 83 | { 84 | "index_key": 0, 85 | "schema_version": 1, 86 | "attributes": { 87 | "arn": "arn:aws:ec2:us-west-2:153052954103:subnet/subnet-023a5a6867d194162", 88 | "assign_ipv6_address_on_creation": false, 89 | "availability_zone": "us-west-2a", 90 | "availability_zone_id": "usw2-az1", 91 | "cidr_block": "10.0.0.0/24", 92 | "id": "subnet-023a5a6867d194162", 93 | "ipv6_cidr_block": "", 94 | "ipv6_cidr_block_association_id": "", 95 | "map_public_ip_on_launch": false, 96 | "outpost_arn": "", 97 | "owner_id": "153052954103", 98 | "tags": null, 99 | "timeouts": null, 100 | "vpc_id": "vpc-0d9ff66ccda7c9765" 101 | }, 102 | "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", 103 | "dependencies": [ 104 | "aws_vpc.vpc" 105 | ] 106 | }, 107 | { 108 | "index_key": 1, 109 | "schema_version": 1, 110 | "attributes": { 111 | "arn": "arn:aws:ec2:us-west-2:153052954103:subnet/subnet-0eea17cb6af21b5e5", 112 | "assign_ipv6_address_on_creation": false, 113 | "availability_zone": "us-west-2d", 114 | "availability_zone_id": "usw2-az4", 115 | "cidr_block": "10.0.1.0/24", 116 | "id": "subnet-0eea17cb6af21b5e5", 117 | "ipv6_cidr_block": "", 118 | "ipv6_cidr_block_association_id": "", 119 | "map_public_ip_on_launch": false, 120 | "outpost_arn": "", 121 | "owner_id": "153052954103", 122 | "tags": null, 123 | "timeouts": null, 124 | "vpc_id": "vpc-0d9ff66ccda7c9765" 125 | }, 126 | "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", 127 | "dependencies": [ 128 | "aws_vpc.vpc" 129 | ] 130 | }, 131 | { 132 | "index_key": 2, 133 | "schema_version": 1, 134 | "attributes": { 135 | "arn": "arn:aws:ec2:us-west-2:153052954103:subnet/subnet-02822dcd2e06634cf", 136 | "assign_ipv6_address_on_creation": false, 137 | "availability_zone": "us-west-2b", 138 | "availability_zone_id": "usw2-az2", 139 | "cidr_block": "10.0.2.0/24", 140 | "id": "subnet-02822dcd2e06634cf", 141 | "ipv6_cidr_block": "", 142 | "ipv6_cidr_block_association_id": "", 143 | "map_public_ip_on_launch": false, 144 | "outpost_arn": "", 145 | "owner_id": "153052954103", 146 | "tags": null, 147 | "timeouts": null, 148 | "vpc_id": "vpc-0d9ff66ccda7c9765" 149 | }, 150 | "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", 151 | "dependencies": [ 152 | "aws_vpc.vpc" 153 | ] 154 | } 155 | ] 156 | }, 157 | { 158 | "mode": "managed", 159 | "type": "aws_vpc", 160 | "name": "vpc", 161 | "provider": "provider.aws", 162 | "instances": [ 163 | { 164 | "schema_version": 1, 165 | "attributes": { 166 | "arn": "arn:aws:ec2:us-west-2:153052954103:vpc/vpc-0d9ff66ccda7c9765", 167 | "assign_generated_ipv6_cidr_block": false, 168 | "cidr_block": "10.0.0.0/16", 169 | "default_network_acl_id": "acl-036f3365d9fb02f93", 170 | "default_route_table_id": "rtb-00135eb80f7463b79", 171 | "default_security_group_id": "sg-021aef186c8246c33", 172 | "dhcp_options_id": "dopt-0b37a96c", 173 | "enable_classiclink": false, 174 | "enable_classiclink_dns_support": false, 175 | "enable_dns_hostnames": false, 176 | "enable_dns_support": true, 177 | "id": "vpc-0d9ff66ccda7c9765", 178 | "instance_tenancy": "default", 179 | "ipv6_association_id": "", 180 | "ipv6_cidr_block": "", 181 | "main_route_table_id": "rtb-00135eb80f7463b79", 182 | "owner_id": "153052954103", 183 | "tags": null 184 | }, 185 | "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" 186 | } 187 | ] 188 | } 189 | ] 190 | } 191 | -------------------------------------------------------------------------------- /examples/local/java/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: java 2 | description: A minimal Java Pulumi program with Maven builds 3 | runtime: java 4 | -------------------------------------------------------------------------------- /examples/local/java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.pulumi 8 | java 9 | 1.0-SNAPSHOT 10 | 11 | 12 | UTF-8 13 | 11 14 | 11 15 | 11 16 | myproject.App 17 | 18 | 19 | 20 | 21 | 22 | com.pulumi 23 | pulumi 24 | [1.3,2.0) 25 | 26 | 27 | com.pulumi 28 | terraform 29 | 30 | 31 | [0.0.0,) 32 | 33 | 34 | 35 | 36 | 37 | com.pulumi 38 | terraform 39 | file:${env.PULUMI_LOCAL_MAVEN} 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-jar-plugin 48 | 3.2.2 49 | 50 | 51 | 52 | true 53 | ${mainClass} 54 | 55 | 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-assembly-plugin 61 | 3.3.0 62 | 63 | 64 | 65 | true 66 | ${mainClass} 67 | 68 | 69 | 70 | jar-with-dependencies 71 | 72 | 73 | 74 | 75 | make-my-jar-with-dependencies 76 | package 77 | 78 | single 79 | 80 | 81 | 82 | 83 | 84 | org.codehaus.mojo 85 | exec-maven-plugin 86 | 3.0.0 87 | 88 | ${mainClass} 89 | ${mainArgs} 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-wrapper-plugin 95 | 3.1.0 96 | 97 | 3.8.5 98 | 99 | 100 | 101 | org.apache.maven.plugins 102 | maven-compiler-plugin 103 | 3.5.1 104 | 105 | 11 106 | 11 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /examples/local/java/src/main/java/myproject/App.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import java.util.List; 4 | import com.pulumi.Pulumi; 5 | import com.pulumi.core.Output; 6 | import com.pulumi.terraform.state.StateFunctions; 7 | import com.pulumi.terraform.state.inputs.GetLocalReferenceArgs; 8 | 9 | public class App { 10 | public static void main(String[] args) { 11 | Pulumi.run(ctx -> { 12 | var output = StateFunctions.getLocalReference(GetLocalReferenceArgs.builder().path("./terraform.0-12-24.tfstate").build()); 13 | ctx.export("state", output.applyValue(x -> x.outputs())); 14 | ctx.export("bucketArn", output.applyValue(x -> x.outputs().get("bucket_arn"))); 15 | ctx.export("firstSubnetId", output.applyValue(x -> ((List)x.outputs().get("public_subnet_ids")).get(0))); 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/local/nodejs/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /node_modules/ 3 | -------------------------------------------------------------------------------- /examples/local/nodejs/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: terraform-local-state-with-typescript 2 | description: Show how to use Pulumi's Terraform provider to read Terraform state in TypeScript. 3 | runtime: 4 | name: nodejs 5 | options: 6 | packagemanager: yarn 7 | -------------------------------------------------------------------------------- /examples/local/nodejs/index.ts: -------------------------------------------------------------------------------- 1 | import { state as tf_state } from "@pulumi/terraform"; 2 | 3 | let outputs = tf_state.getLocalReferenceOutput({ 4 | path: "./terraform.0-12-24.tfstate", 5 | }).outputs; 6 | 7 | export const state = outputs; 8 | export const bucketArn = outputs["bucket_arn"]; 9 | export const firstSubnetId = outputs["public_subnet_ids"].apply(x => x[0]); 10 | -------------------------------------------------------------------------------- /examples/local/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "terraform-local-state-with-typescript", 3 | "main": "index.ts", 4 | "devDependencies": { 5 | "@types/node": "^18", 6 | "typescript": "^5.0.0" 7 | }, 8 | "dependencies": { 9 | "@pulumi/pulumi": "^3.159.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/local/nodejs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "outDir": "bin", 5 | "target": "es2020", 6 | "module": "commonjs", 7 | "moduleResolution": "node", 8 | "sourceMap": true, 9 | "experimentalDecorators": true, 10 | "pretty": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "noImplicitReturns": true, 13 | "forceConsistentCasingInFileNames": true 14 | }, 15 | "files": [ 16 | "index.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /examples/local/python/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | venv/ 3 | __pycache__/ -------------------------------------------------------------------------------- /examples/local/python/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: python 2 | description: A minimal Python Pulumi program 3 | runtime: 4 | name: python 5 | options: 6 | toolchain: pip 7 | virtualenv: venv 8 | config: 9 | pulumi:tags: 10 | value: 11 | pulumi:template: python 12 | -------------------------------------------------------------------------------- /examples/local/python/__main__.py: -------------------------------------------------------------------------------- 1 | import pulumi 2 | import pulumi_terraform as terraform 3 | 4 | outputs = terraform.state.get_local_reference(path="./terraform.0-12-24.tfstate").outputs 5 | 6 | pulumi.export("state", outputs) 7 | pulumi.export("bucketArn", outputs["bucket_arn"]) 8 | pulumi.export("firstSubnetId", outputs["public_subnet_ids"][0]) 9 | -------------------------------------------------------------------------------- /examples/local/python/requirements.txt: -------------------------------------------------------------------------------- 1 | pulumi>=3.0.0,<4.0.0 2 | -------------------------------------------------------------------------------- /examples/local/yaml/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: terraform-local-state-with-yaml 2 | runtime: yaml 3 | variables: 4 | state: 5 | fn::invoke: 6 | function: terraform:state:getLocalReference 7 | arguments: 8 | path: ./terraform.0-12-24.tfstate 9 | return: outputs 10 | publicSubnetIds: 11 | fn::std:tolist: 12 | input: ${state["public_subnet_ids"]} 13 | 14 | 15 | outputs: 16 | state: ${state} 17 | bucketArn: ${state["bucket_arn"]} 18 | firstSubnetId: ${publicSubnetIds.result[0]} 19 | -------------------------------------------------------------------------------- /examples/remote/go/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: terraform-remote-state-with-go 2 | runtime: go 3 | description: An example demonstrating the Terraform Remote State resource in Go 4 | config: 5 | terraform-remote-state-with-go:workspaces_prefix: dev -------------------------------------------------------------------------------- /examples/remote/go/go.mod: -------------------------------------------------------------------------------- 1 | module terraform-remote-state-with-go 2 | 3 | go 1.22 4 | 5 | toolchain go1.24.1 6 | 7 | replace github.com/pulumi/pulumi-terraform/sdk/v6 => ../../../sdk 8 | 9 | require ( 10 | github.com/pulumi/pulumi-terraform/sdk/v6 v6.0.0-00010101000000-000000000000 11 | github.com/pulumi/pulumi/sdk/v3 v3.160.0 12 | ) 13 | 14 | require ( 15 | dario.cat/mergo v1.0.0 // indirect 16 | github.com/BurntSushi/toml v1.2.1 // indirect 17 | github.com/Microsoft/go-winio v0.6.1 // indirect 18 | github.com/ProtonMail/go-crypto v1.1.3 // indirect 19 | github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect 20 | github.com/agext/levenshtein v1.2.3 // indirect 21 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect 22 | github.com/atotto/clipboard v0.1.4 // indirect 23 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 24 | github.com/blang/semver v3.5.1+incompatible // indirect 25 | github.com/charmbracelet/bubbles v0.16.1 // indirect 26 | github.com/charmbracelet/bubbletea v0.25.0 // indirect 27 | github.com/charmbracelet/lipgloss v0.7.1 // indirect 28 | github.com/cheggaaa/pb v1.0.29 // indirect 29 | github.com/cloudflare/circl v1.3.7 // indirect 30 | github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect 31 | github.com/cyphar/filepath-securejoin v0.3.6 // indirect 32 | github.com/djherbis/times v1.5.0 // indirect 33 | github.com/emirpasic/gods v1.18.1 // indirect 34 | github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect 35 | github.com/go-git/go-billy/v5 v5.6.1 // indirect 36 | github.com/go-git/go-git/v5 v5.13.1 // indirect 37 | github.com/gogo/protobuf v1.3.2 // indirect 38 | github.com/golang/glog v1.2.4 // indirect 39 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 40 | github.com/google/uuid v1.6.0 // indirect 41 | github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect 42 | github.com/hashicorp/errwrap v1.1.0 // indirect 43 | github.com/hashicorp/go-multierror v1.1.1 // indirect 44 | github.com/hashicorp/hcl/v2 v2.17.0 // indirect 45 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 46 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect 47 | github.com/kevinburke/ssh_config v1.2.0 // indirect 48 | github.com/lucasb-eyer/go-colorful v1.2.0 // indirect 49 | github.com/mattn/go-isatty v0.0.19 // indirect 50 | github.com/mattn/go-localereader v0.0.1 // indirect 51 | github.com/mattn/go-runewidth v0.0.15 // indirect 52 | github.com/mitchellh/go-ps v1.0.0 // indirect 53 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect 54 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect 55 | github.com/muesli/cancelreader v0.2.2 // indirect 56 | github.com/muesli/reflow v0.3.0 // indirect 57 | github.com/muesli/termenv v0.15.2 // indirect 58 | github.com/opentracing/basictracer-go v1.1.0 // indirect 59 | github.com/opentracing/opentracing-go v1.2.0 // indirect 60 | github.com/pgavlin/fx v0.1.6 // indirect 61 | github.com/pjbgf/sha1cd v0.3.0 // indirect 62 | github.com/pkg/errors v0.9.1 // indirect 63 | github.com/pkg/term v1.1.0 // indirect 64 | github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect 65 | github.com/pulumi/esc v0.9.1 // indirect 66 | github.com/rivo/uniseg v0.4.4 // indirect 67 | github.com/rogpeppe/go-internal v1.12.0 // indirect 68 | github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect 69 | github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect 70 | github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect 71 | github.com/skeema/knownhosts v1.3.0 // indirect 72 | github.com/spf13/cast v1.4.1 // indirect 73 | github.com/spf13/cobra v1.7.0 // indirect 74 | github.com/spf13/pflag v1.0.5 // indirect 75 | github.com/texttheater/golang-levenshtein v1.0.1 // indirect 76 | github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect 77 | github.com/uber/jaeger-lib v2.4.1+incompatible // indirect 78 | github.com/xanzy/ssh-agent v0.3.3 // indirect 79 | github.com/zclconf/go-cty v1.13.2 // indirect 80 | go.uber.org/atomic v1.9.0 // indirect 81 | golang.org/x/crypto v0.33.0 // indirect 82 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect 83 | golang.org/x/mod v0.19.0 // indirect 84 | golang.org/x/net v0.35.0 // indirect 85 | golang.org/x/sync v0.11.0 // indirect 86 | golang.org/x/sys v0.30.0 // indirect 87 | golang.org/x/term v0.29.0 // indirect 88 | golang.org/x/text v0.22.0 // indirect 89 | golang.org/x/tools v0.23.0 // indirect 90 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect 91 | google.golang.org/grpc v1.63.2 // indirect 92 | google.golang.org/protobuf v1.33.0 // indirect 93 | gopkg.in/warnings.v0 v0.1.2 // indirect 94 | gopkg.in/yaml.v3 v3.0.1 // indirect 95 | lukechampine.com/frand v1.4.2 // indirect 96 | ) 97 | -------------------------------------------------------------------------------- /examples/remote/go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 5 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" 6 | 7 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/state" 8 | ) 9 | 10 | func main() { 11 | pulumi.Run(func(ctx *pulumi.Context) error { 12 | conf := config.New(ctx, "") 13 | token := conf.RequireSecret("remote_tf_token") 14 | organization := conf.Require("remote_tf_org") 15 | workspacesPrefiix := conf.Require("workspaces_prefix") 16 | 17 | state := state.GetRemoteReferenceOutput(ctx, state.GetRemoteReferenceOutputArgs{ 18 | Organization: pulumi.String(organization), 19 | Token: pulumi.StringInput(token), 20 | Workspaces: state.WorkspacesArgs{ 21 | Prefix: pulumi.StringPtr(workspacesPrefiix), 22 | }, 23 | }) 24 | ctx.Export("state", state.Outputs()) 25 | return nil 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /examples/remote/yaml/Pulumi.yaml: -------------------------------------------------------------------------------- 1 | name: terraform-remote-state-with-yaml 2 | runtime: yaml 3 | outputs: 4 | state: 5 | fn::invoke: 6 | function: terraform:state:getRemoteReference 7 | arguments: 8 | organization: ${remote_tf_org} # A config value - sourced from TFE_ORGANIZATION in testing 9 | token: 10 | fn::secret: ${remote_tf_token} # A config value - sourced from TFE_TOKEN in testing 11 | workspaces: 12 | prefix: dev 13 | return: outputs 14 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2022, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | p "github.com/pulumi/pulumi-go-provider" 22 | 23 | terraform "github.com/pulumi/pulumi-terraform/v6/provider" 24 | "github.com/pulumi/pulumi-terraform/v6/provider/version" 25 | ) 26 | 27 | func main() { 28 | // This method defines the provider implemented in this repository. 29 | terraformProvider := terraform.NewProvider() 30 | 31 | // This method starts serving requests using the Terraform provider. 32 | err := p.RunProvider("terraform", version.Version.String(), terraformProvider) 33 | if err != nil { 34 | fmt.Fprintf(os.Stderr, "Error: %s", err.Error()) 35 | os.Exit(1) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /provider/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2018, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package provider 16 | 17 | import ( 18 | "bufio" 19 | "context" 20 | "strings" 21 | 22 | p "github.com/pulumi/pulumi-go-provider" 23 | "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" 24 | ) 25 | 26 | // LogRedirector creates a new redirection writer that takes as input plugin stderr output, and routes it to the 27 | // correct Pulumi stream based on the standard Terraform logging output prefixes. 28 | type LogRedirector struct { 29 | enabled bool // true if standard logging is on; false for debug-only. 30 | writers map[string]func(string) error // the writers for certain labels. 31 | buffer []byte // a buffer that holds up to a line of output. 32 | } 33 | 34 | // NewTerraformLogRedirector returns a new LogRedirector with the (unexported) writers field 35 | // set to the given map. 36 | func NewTerraformLogRedirector(ctx context.Context) *LogRedirector { 37 | logger := p.GetLogger(ctx) 38 | return &LogRedirector{ 39 | writers: map[string]func(string) error{ 40 | tfTracePrefix: func(msg string) error { logger.Debug(msg); return nil }, 41 | tfDebugPrefix: func(msg string) error { logger.Debug(msg); return nil }, 42 | tfInfoPrefix: func(msg string) error { logger.Info(msg); return nil }, 43 | tfWarnPrefix: func(msg string) error { logger.Warning(msg); return nil }, 44 | tfErrorPrefix: func(msg string) error { logger.Error(msg); return nil }, 45 | }, 46 | } 47 | } 48 | 49 | const ( 50 | tfTracePrefix = "[TRACE]" 51 | tfDebugPrefix = "[DEBUG]" 52 | tfInfoPrefix = "[INFO]" 53 | tfWarnPrefix = "[WARN]" 54 | tfErrorPrefix = "[ERROR]" 55 | ) 56 | 57 | // Enable turns on full featured logging. This is the default. 58 | func (lr *LogRedirector) Enable() { 59 | lr.enabled = true 60 | } 61 | 62 | // Disable disables most of the specific logging levels, but it retains debug logging. 63 | func (lr *LogRedirector) Disable() { 64 | lr.enabled = false 65 | } 66 | 67 | func (lr *LogRedirector) Write(p []byte) (n int, err error) { 68 | written := 0 69 | 70 | // If a line starts with [TRACE], [DEBUG], or [INFO], then we emit to a debug log entry. If a line starts with 71 | // [WARN], we emit a warning. If a line starts with [ERROR], on the other hand, we emit a normal stderr line. 72 | // All others simply get redirected to stdout as normal output. 73 | for len(p) > 0 { 74 | adv, tok, err := bufio.ScanLines(p, false) 75 | if err != nil { 76 | return written, err 77 | } 78 | 79 | // If adv == 0, there was no newline; buffer it all and move on. 80 | if adv == 0 { 81 | lr.buffer = append(lr.buffer, p...) 82 | written += len(p) 83 | break 84 | } 85 | 86 | // Otherwise, there was a newline; emit the buffer plus payload to the right place, and keep going if 87 | // there is more. 88 | lr.buffer = append(lr.buffer, tok...) // append the buffer. 89 | s := string(lr.buffer) 90 | 91 | // To do this we need to parse the label if there is one (e.g., [TRACE], et al). 92 | var label string 93 | if start := strings.IndexRune(s, '['); start != -1 { 94 | if end := strings.Index(s[start:], "] "); end != -1 { 95 | label = s[start : start+end+1] 96 | s = s[start+end+2:] // skip past the "] " (notice the space) 97 | } 98 | } 99 | w, has := lr.writers[label] 100 | if !has || !lr.enabled { 101 | // If there was no writer for this label, or logging is disabled, use the debug label. 102 | w = lr.writers[tfDebugPrefix] 103 | contract.Assertf(w != nil, "No writer should be nil") 104 | } 105 | if err := w(s); err != nil { 106 | return written, err 107 | } 108 | 109 | // Now keep moving on provided there is more left in the buffer. 110 | lr.buffer = lr.buffer[:0] // clear out the buffer. 111 | p = p[adv:] // advance beyond the extracted region. 112 | written += adv 113 | } 114 | 115 | return written, nil 116 | } 117 | -------------------------------------------------------------------------------- /provider/provider.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2022, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package provider 16 | 17 | import ( 18 | "context" 19 | "fmt" 20 | 21 | p "github.com/pulumi/pulumi-go-provider" 22 | "github.com/pulumi/pulumi-go-provider/infer" 23 | "github.com/pulumi/pulumi-go-provider/middleware/schema" 24 | "github.com/pulumi/pulumi-terraform/v6/provider/state_reference" 25 | "github.com/pulumi/pulumi-terraform/v6/provider/version" 26 | "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" 27 | ) 28 | 29 | const ( 30 | Name = "terraform" 31 | ) 32 | 33 | // This provider uses the `pulumi-go-provider` library to produce a code-first provider definition. 34 | func NewProvider() p.Provider { 35 | pkg := infer.Provider(infer.Options{ 36 | // This is the metadata for the provider 37 | Metadata: schema.Metadata{ 38 | DisplayName: "Terraform", 39 | Description: "The Terraform provider for Pulumi lets you consume the outputs " + 40 | "contained in Terraform state from your Pulumi programs.", 41 | Keywords: []string{ 42 | "terraform", 43 | "kind/native", 44 | "category/utility", 45 | }, 46 | Homepage: "https://pulumi.com", 47 | License: "Apache-2.0", 48 | Repository: "https://github.com/pulumi/pulumi-terraform", 49 | Publisher: "Pulumi", 50 | LogoURL: "https://raw.githubusercontent.com/pulumi/pulumi-terraform-provider/main/assets/logo.png", 51 | LanguageMap: map[string]any{ 52 | "csharp": map[string]any{ 53 | "respectSchemaVersion": true, 54 | "packageReferences": map[string]string{ 55 | "Pulumi": "3.*", 56 | }, 57 | }, 58 | "go": map[string]any{ 59 | "respectSchemaVersion": true, 60 | "generateResourceContainerTypes": true, 61 | "importBasePath": fmt.Sprintf( 62 | "github.com/pulumi/pulumi-terraform/sdk/v%d/go/terraform", version.Version.Major), 63 | }, 64 | "nodejs": map[string]any{ 65 | "respectSchemaVersion": true, 66 | }, 67 | "python": map[string]any{ 68 | "respectSchemaVersion": true, 69 | "pyproject": map[string]bool{ 70 | "enabled": true, 71 | }, 72 | }, 73 | "java": map[string]any{ 74 | "buildFiles": "gradle", 75 | "gradleNexusPublishPluginVersion": "2.0.0", 76 | "dependencies": map[string]any{ 77 | "com.pulumi:pulumi": "1.0.0", 78 | "com.google.code.gson:gson": "2.8.9", 79 | "com.google.code.findbugs:jsr305": "3.0.2", 80 | }, 81 | }, 82 | }, 83 | }, 84 | Functions: []infer.InferredFunction{ 85 | infer.Function[*provider.GetLocalReference](), 86 | infer.Function[*provider.GetRemoteReference](), 87 | }, 88 | ModuleMap: map[tokens.ModuleName]tokens.ModuleName{ 89 | "state_reference": "state", 90 | }, 91 | }) 92 | 93 | { 94 | // Initialize the TF back-end exactly once during provider configuration 95 | oldConfigure := pkg.Configure 96 | pkg.Configure = func(ctx context.Context, req p.ConfigureRequest) error { 97 | NewTerraformLogRedirector(ctx) 98 | provider.InitTfBackend() 99 | if oldConfigure != nil { 100 | return oldConfigure(ctx, req) 101 | } 102 | return nil 103 | } 104 | } 105 | 106 | return pkg 107 | } 108 | -------------------------------------------------------------------------------- /provider/shim/shim.go: -------------------------------------------------------------------------------- 1 | package shim 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/hashicorp/terraform-svchost/disco" 9 | backendInit "github.com/hashicorp/terraform/internal/backend/init" 10 | "github.com/zclconf/go-cty/cty" 11 | ctyjson "github.com/zclconf/go-cty/cty/json" 12 | "google.golang.org/grpc/codes" 13 | "google.golang.org/grpc/status" 14 | ) 15 | 16 | func InitTfBackend() { backendInit.Init(disco.New()) } 17 | 18 | func StateReferenceRead( 19 | ctx context.Context, 20 | backendType string, 21 | workspaceName string, 22 | backendConfigValue map[string]cty.Value, 23 | ) (map[string]any, error) { 24 | // Ensure the backendType is known about by Terraform 25 | backendInitFn := backendInit.Backend(backendType) 26 | if backendInitFn == nil { 27 | return nil, status.Errorf(codes.InvalidArgument, "unsupported backend type %q", backendType) 28 | } 29 | 30 | // Get the configuration schema from the backend 31 | backend := backendInitFn() 32 | 33 | // Attempt to coerce our config object into the config schema types - note errors 34 | backendConfigCoerced, err := backend.ConfigSchema().CoerceValue(cty.ObjectVal(backendConfigValue)) 35 | if err != nil { 36 | return nil, status.Errorf(codes.Internal, "error coercing config from Pulumi format to cty: %s", err) 37 | } 38 | 39 | // Attempt to prepare the backend with configuration, returning any diagnostics to the engine 40 | preparedBackendConfig, diagnostics := backend.PrepareConfig(backendConfigCoerced) 41 | if diagnostics.HasErrors() { 42 | return nil, status.Errorf(codes.Internal, "error preparing config: %s", diagnostics.Err()) 43 | } 44 | 45 | // Actually prepare the backend with the valid configuration 46 | diagnostics = backend.Configure(preparedBackendConfig) 47 | if diagnostics.HasErrors() { 48 | return nil, status.Errorf(codes.InvalidArgument, "error in backend configuration: %s", 49 | diagnostics.ErrWithWarnings()) 50 | } 51 | 52 | // Get the state manager from the backend for the appropriate workspace 53 | stateManager, err := backend.StateMgr(workspaceName) 54 | if err != nil { 55 | return nil, status.Errorf(codes.Internal, "error constructing backend state manager: %s", err) 56 | } 57 | 58 | // Refresh the state 59 | if err := stateManager.RefreshState(); err != nil { 60 | return nil, status.Errorf(codes.NotFound, "error refreshing Terraform state: %s", err) 61 | } 62 | 63 | // Check the state isn't empty 64 | state := stateManager.State() 65 | if state == nil { 66 | return nil, status.Error(codes.NotFound, "remote state not found") 67 | } 68 | 69 | // Convert back into the type that we expect. 70 | 71 | outputs := map[string]any{} 72 | for k, v := range state.RootModule().OutputValues { 73 | jsonBytes, err := ctyjson.Marshal(v.Value, v.Value.Type()) 74 | if err != nil { 75 | return nil, fmt.Errorf("error marshaling cty to JSON: %w", err) 76 | } 77 | var goV any 78 | if err := json.Unmarshal(jsonBytes, &goV); err != nil { 79 | return nil, fmt.Errorf("error unmarshaling JSON: %w", err) 80 | } 81 | outputs[k] = goV 82 | } 83 | return outputs, nil 84 | } 85 | -------------------------------------------------------------------------------- /provider/state_reference/local.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package provider 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/hashicorp/terraform/shim" 21 | "github.com/pulumi/pulumi-go-provider/infer" 22 | "github.com/zclconf/go-cty/cty" 23 | ) 24 | 25 | type GetLocalReference struct{} 26 | 27 | var _ = (infer.Annotated)((*GetLocalReference)(nil)) 28 | 29 | func (r *GetLocalReference) Annotate(a infer.Annotator) { 30 | a.Describe(&r, "Access state from the local filesystem.") 31 | } 32 | 33 | // Taken from https://developer.hashicorp.com/terraform/language/backend/local#configuration-variables 34 | type GetLocalReferenceArgs struct { 35 | Path *string `pulumi:"path,optional"` 36 | WorkspaceDir *string `pulumi:"workspaceDir,optional"` 37 | } 38 | 39 | func (r *GetLocalReferenceArgs) Annotate(a infer.Annotator) { 40 | a.Describe(&r.Path, `The path to the tfstate file. This defaults to `+ 41 | `"terraform.tfstate" relative to the root module by default.`) 42 | a.Describe(&r.WorkspaceDir, `The path to non-default workspaces.`) 43 | } 44 | 45 | func (r *GetLocalReference) Call( 46 | ctx context.Context, args GetLocalReferenceArgs, 47 | ) (StateReferenceOutputs, error) { 48 | results, err := shim.StateReferenceRead(ctx, "local", "", map[string]cty.Value{ 49 | "path": ctyStringOrNil(args.Path), 50 | "workspace_dir": ctyStringOrNil(args.WorkspaceDir), 51 | }) 52 | 53 | return StateReferenceOutputs{results}, err 54 | } 55 | -------------------------------------------------------------------------------- /provider/state_reference/remote.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2025, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package provider 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/hashicorp/terraform/shim" 21 | "github.com/pulumi/pulumi-go-provider/infer" 22 | "github.com/zclconf/go-cty/cty" 23 | ) 24 | 25 | type GetRemoteReference struct{} 26 | 27 | var ( 28 | _ = (infer.Annotated)((*GetRemoteReference)(nil)) 29 | _ = (infer.ExplicitDependencies[GetRemoteReferenceArgs, StateReferenceOutputs])((*GetRemoteReference)(nil)) 30 | ) 31 | 32 | func (r *GetRemoteReference) Annotate(a infer.Annotator) { 33 | a.Describe(&r, "Access state from a remote backend.") 34 | } 35 | 36 | // Taken from https://developer.hashicorp.com/terraform/language/backend/remote#configuration-variables 37 | type GetRemoteReferenceArgs struct { 38 | Hostname *string `pulumi:"hostname,optional"` 39 | Organization string `pulumi:"organization"` 40 | Token *string `pulumi:"token,optional" provider:"secret"` 41 | Workspaces Workspaces `pulumi:"workspaces"` 42 | } 43 | 44 | func (r *GetRemoteReferenceArgs) Annotate(a infer.Annotator) { 45 | a.Describe(&r.Hostname, "The remote backend hostname to connect to.") 46 | a.Describe(&r.Organization, "The name of the organization containing the targeted workspace(s).") 47 | a.Describe(&r.Token, "The token used to authenticate with the remote backend.") 48 | 49 | a.SetDefault(&r.Hostname, "app.terraform.io") 50 | } 51 | 52 | // WireDependencies lets us tell user's that our outputs shouldn't be secret, even when 53 | // the token (when provided) is always secret. 54 | // 55 | // TODO[https://github.com/pulumi/pulumi-go-provider/issues/323]: This doesn't currently 56 | // work; [infer.ExplicitDependencies] is not currently implemented for [infer] based 57 | // functions. 58 | func (r *GetRemoteReference) WireDependencies( 59 | f infer.FieldSelector, _ *GetRemoteReferenceArgs, state *StateReferenceOutputs, 60 | ) { 61 | f.OutputField(&state).NeverSecret() // The output should never be secret by default 62 | } 63 | 64 | type Workspaces struct { 65 | Name *string `pulumi:"name,optional"` 66 | Prefix *string `pulumi:"prefix,optional"` 67 | } 68 | 69 | func (r *Workspaces) Annotate(a infer.Annotator) { 70 | a.Describe(&r.Name, "The full name of one remote workspace. When configured, only the default workspace can be "+ 71 | "used. This option conflicts with prefix.") 72 | a.Describe(&r.Prefix, "A prefix used in the names of one or more remote workspaces, all of which can be used "+ 73 | "with this configuration. The full workspace names are used in HCP Terraform, and the short names "+ 74 | "(minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only "+ 75 | "the default workspace can be used. This option conflicts with name.") 76 | } 77 | 78 | func (r *GetRemoteReference) Call( 79 | ctx context.Context, args GetRemoteReferenceArgs, 80 | ) (StateReferenceOutputs, error) { 81 | results, err := shim.StateReferenceRead(ctx, "remote", stringOrZero(args.Workspaces.Name), map[string]cty.Value{ 82 | "hostname": ctyStringOrNil(args.Hostname), 83 | "organization": cty.StringVal(args.Organization), 84 | "token": ctyStringOrNil(args.Token), 85 | "workspaces": cty.ObjectVal(map[string]cty.Value{ 86 | "name": ctyStringOrNil(args.Workspaces.Name), 87 | "prefix": ctyStringOrNil(args.Workspaces.Prefix), 88 | }), 89 | }) 90 | 91 | return StateReferenceOutputs{results}, err 92 | } 93 | -------------------------------------------------------------------------------- /provider/state_reference/state_reference.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2022, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package provider 16 | 17 | import ( 18 | "github.com/hashicorp/terraform/shim" 19 | "github.com/pulumi/pulumi-go-provider/infer" 20 | "github.com/zclconf/go-cty/cty" 21 | ) 22 | 23 | func InitTfBackend() { shim.InitTfBackend() } 24 | 25 | type StateReferenceOutputs struct { 26 | // Outputs is a map of the outputs from the Terraform state file 27 | Outputs map[string]any `pulumi:"outputs"` 28 | } 29 | 30 | var _ = (infer.Annotated)((*StateReferenceOutputs)(nil)) 31 | 32 | // Implementing Annotate lets you provide descriptions and default values for resources and they will 33 | // be visible in the provider's schema and the generated SDKs. 34 | func (r *StateReferenceOutputs) Annotate(a infer.Annotator) { 35 | a.Describe(&r, "The result of fetching from a Terraform state store.") 36 | a.Describe(&r.Outputs, "The outputs displayed from Terraform state.") 37 | } 38 | 39 | func ctyStringOrNil(v *string) cty.Value { 40 | if v == nil { 41 | return cty.NullVal(cty.String) 42 | } 43 | return cty.StringVal(*v) 44 | } 45 | 46 | func stringOrZero(v *string) string { 47 | if v == nil { 48 | return "" 49 | } 50 | return *v 51 | } 52 | -------------------------------------------------------------------------------- /provider/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2018, Pulumi Corporation. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package version 16 | 17 | import ( 18 | "strings" 19 | 20 | "github.com/blang/semver" 21 | ) 22 | 23 | var Version semver.Version = semver.MustParse(strings.TrimPrefix(version, "v")) 24 | 25 | // Version is initialized by the Go linker to contain the semver of this build. 26 | var version string 27 | -------------------------------------------------------------------------------- /schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "terraform", 3 | "displayName": "Terraform", 4 | "description": "The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs.", 5 | "keywords": [ 6 | "terraform", 7 | "kind/native", 8 | "category/utility" 9 | ], 10 | "homepage": "https://pulumi.com", 11 | "license": "Apache-2.0", 12 | "repository": "https://github.com/pulumi/pulumi-terraform", 13 | "logoUrl": "https://raw.githubusercontent.com/pulumi/pulumi-terraform-provider/main/assets/logo.png", 14 | "publisher": "Pulumi", 15 | "meta": { 16 | "moduleFormat": "(.*)" 17 | }, 18 | "language": { 19 | "csharp": { 20 | "packageReferences": { 21 | "Pulumi": "3.*" 22 | }, 23 | "respectSchemaVersion": true 24 | }, 25 | "go": { 26 | "generateResourceContainerTypes": true, 27 | "importBasePath": "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform", 28 | "respectSchemaVersion": true 29 | }, 30 | "java": { 31 | "buildFiles": "gradle", 32 | "dependencies": { 33 | "com.google.code.findbugs:jsr305": "3.0.2", 34 | "com.google.code.gson:gson": "2.8.9", 35 | "com.pulumi:pulumi": "1.0.0" 36 | }, 37 | "gradleNexusPublishPluginVersion": "2.0.0" 38 | }, 39 | "nodejs": { 40 | "respectSchemaVersion": true 41 | }, 42 | "python": { 43 | "pyproject": { 44 | "enabled": true 45 | }, 46 | "respectSchemaVersion": true 47 | } 48 | }, 49 | "config": {}, 50 | "types": { 51 | "terraform:state:Workspaces": { 52 | "properties": { 53 | "name": { 54 | "type": "string", 55 | "description": "The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix." 56 | }, 57 | "prefix": { 58 | "type": "string", 59 | "description": "A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name." 60 | } 61 | }, 62 | "type": "object" 63 | } 64 | }, 65 | "provider": { 66 | "type": "object" 67 | }, 68 | "functions": { 69 | "terraform:state:getLocalReference": { 70 | "description": "Access state from the local filesystem.", 71 | "inputs": { 72 | "properties": { 73 | "path": { 74 | "type": "string", 75 | "description": "The path to the tfstate file. This defaults to \"terraform.tfstate\" relative to the root module by default." 76 | }, 77 | "workspaceDir": { 78 | "type": "string", 79 | "description": "The path to non-default workspaces." 80 | } 81 | }, 82 | "type": "object" 83 | }, 84 | "outputs": { 85 | "description": "The result of fetching from a Terraform state store.", 86 | "properties": { 87 | "outputs": { 88 | "additionalProperties": { 89 | "$ref": "pulumi.json#/Any" 90 | }, 91 | "description": "The outputs displayed from Terraform state.", 92 | "type": "object" 93 | } 94 | }, 95 | "required": [ 96 | "outputs" 97 | ], 98 | "type": "object" 99 | } 100 | }, 101 | "terraform:state:getRemoteReference": { 102 | "description": "Access state from a remote backend.", 103 | "inputs": { 104 | "properties": { 105 | "hostname": { 106 | "type": "string", 107 | "description": "The remote backend hostname to connect to.", 108 | "default": "app.terraform.io" 109 | }, 110 | "organization": { 111 | "type": "string", 112 | "description": "The name of the organization containing the targeted workspace(s)." 113 | }, 114 | "token": { 115 | "type": "string", 116 | "description": "The token used to authenticate with the remote backend.", 117 | "secret": true 118 | }, 119 | "workspaces": { 120 | "$ref": "#/types/terraform:state:Workspaces" 121 | } 122 | }, 123 | "type": "object", 124 | "required": [ 125 | "organization", 126 | "workspaces" 127 | ] 128 | }, 129 | "outputs": { 130 | "description": "The result of fetching from a Terraform state store.", 131 | "properties": { 132 | "outputs": { 133 | "additionalProperties": { 134 | "$ref": "pulumi.json#/Any" 135 | }, 136 | "description": "The outputs displayed from Terraform state.", 137 | "type": "object" 138 | } 139 | }, 140 | "required": [ 141 | "outputs" 142 | ], 143 | "type": "object" 144 | } 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /sdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | yarn.lock 3 | package-lock.json 4 | bin/ 5 | -------------------------------------------------------------------------------- /sdk/dotnet/Provider.cs: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.Threading.Tasks; 8 | using Pulumi.Serialization; 9 | 10 | namespace Pulumi.Terraform 11 | { 12 | [TerraformResourceType("pulumi:providers:terraform")] 13 | public partial class Provider : global::Pulumi.ProviderResource 14 | { 15 | /// 16 | /// Create a Provider resource with the given unique name, arguments, and options. 17 | /// 18 | /// 19 | /// The unique name of the resource 20 | /// The arguments used to populate this resource's properties 21 | /// A bag of options that control this resource's behavior 22 | public Provider(string name, ProviderArgs? args = null, CustomResourceOptions? options = null) 23 | : base("terraform", name, args ?? new ProviderArgs(), MakeResourceOptions(options, "")) 24 | { 25 | } 26 | 27 | private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input? id) 28 | { 29 | var defaultOptions = new CustomResourceOptions 30 | { 31 | Version = Utilities.Version, 32 | }; 33 | var merged = CustomResourceOptions.Merge(defaultOptions, options); 34 | // Override the ID if one was specified for consistency with other language SDKs. 35 | merged.Id = id ?? merged.Id; 36 | return merged; 37 | } 38 | } 39 | 40 | public sealed class ProviderArgs : global::Pulumi.ResourceArgs 41 | { 42 | public ProviderArgs() 43 | { 44 | } 45 | public static new ProviderArgs Empty => new ProviderArgs(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sdk/dotnet/Pulumi.Terraform.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | Pulumi 6 | Pulumi 7 | The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 8 | Apache-2.0 9 | https://pulumi.com 10 | https://github.com/pulumi/pulumi-terraform 11 | logo.png 12 | 6.0.0-alpha.0+dev 13 | 14 | net6.0 15 | enable 16 | 17 | 18 | 19 | true 20 | 1701;1702;1591 21 | 22 | 23 | 24 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb 25 | true 26 | true 27 | 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | True 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /sdk/dotnet/README.md: -------------------------------------------------------------------------------- 1 | The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 2 | -------------------------------------------------------------------------------- /sdk/dotnet/State/GetLocalReference.cs: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.Threading.Tasks; 8 | using Pulumi.Serialization; 9 | 10 | namespace Pulumi.Terraform.State 11 | { 12 | public static class GetLocalReference 13 | { 14 | /// 15 | /// Access state from the local filesystem. 16 | /// 17 | public static Task InvokeAsync(GetLocalReferenceArgs? args = null, InvokeOptions? options = null) 18 | => global::Pulumi.Deployment.Instance.InvokeAsync("terraform:state:getLocalReference", args ?? new GetLocalReferenceArgs(), options.WithDefaults()); 19 | 20 | /// 21 | /// Access state from the local filesystem. 22 | /// 23 | public static Output Invoke(GetLocalReferenceInvokeArgs? args = null, InvokeOptions? options = null) 24 | => global::Pulumi.Deployment.Instance.Invoke("terraform:state:getLocalReference", args ?? new GetLocalReferenceInvokeArgs(), options.WithDefaults()); 25 | 26 | /// 27 | /// Access state from the local filesystem. 28 | /// 29 | public static Output Invoke(GetLocalReferenceInvokeArgs args, InvokeOutputOptions options) 30 | => global::Pulumi.Deployment.Instance.Invoke("terraform:state:getLocalReference", args ?? new GetLocalReferenceInvokeArgs(), options.WithDefaults()); 31 | } 32 | 33 | 34 | public sealed class GetLocalReferenceArgs : global::Pulumi.InvokeArgs 35 | { 36 | /// 37 | /// The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 38 | /// 39 | [Input("path")] 40 | public string? Path { get; set; } 41 | 42 | /// 43 | /// The path to non-default workspaces. 44 | /// 45 | [Input("workspaceDir")] 46 | public string? WorkspaceDir { get; set; } 47 | 48 | public GetLocalReferenceArgs() 49 | { 50 | } 51 | public static new GetLocalReferenceArgs Empty => new GetLocalReferenceArgs(); 52 | } 53 | 54 | public sealed class GetLocalReferenceInvokeArgs : global::Pulumi.InvokeArgs 55 | { 56 | /// 57 | /// The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 58 | /// 59 | [Input("path")] 60 | public Input? Path { get; set; } 61 | 62 | /// 63 | /// The path to non-default workspaces. 64 | /// 65 | [Input("workspaceDir")] 66 | public Input? WorkspaceDir { get; set; } 67 | 68 | public GetLocalReferenceInvokeArgs() 69 | { 70 | } 71 | public static new GetLocalReferenceInvokeArgs Empty => new GetLocalReferenceInvokeArgs(); 72 | } 73 | 74 | 75 | [OutputType] 76 | public sealed class GetLocalReferenceResult 77 | { 78 | /// 79 | /// The outputs displayed from Terraform state. 80 | /// 81 | public readonly ImmutableDictionary Outputs; 82 | 83 | [OutputConstructor] 84 | private GetLocalReferenceResult(ImmutableDictionary outputs) 85 | { 86 | Outputs = outputs; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /sdk/dotnet/State/GetRemoteReference.cs: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.Threading.Tasks; 8 | using Pulumi.Serialization; 9 | 10 | namespace Pulumi.Terraform.State 11 | { 12 | public static class GetRemoteReference 13 | { 14 | /// 15 | /// Access state from a remote backend. 16 | /// 17 | public static Task InvokeAsync(GetRemoteReferenceArgs args, InvokeOptions? options = null) 18 | => global::Pulumi.Deployment.Instance.InvokeAsync("terraform:state:getRemoteReference", args ?? new GetRemoteReferenceArgs(), options.WithDefaults()); 19 | 20 | /// 21 | /// Access state from a remote backend. 22 | /// 23 | public static Output Invoke(GetRemoteReferenceInvokeArgs args, InvokeOptions? options = null) 24 | => global::Pulumi.Deployment.Instance.Invoke("terraform:state:getRemoteReference", args ?? new GetRemoteReferenceInvokeArgs(), options.WithDefaults()); 25 | 26 | /// 27 | /// Access state from a remote backend. 28 | /// 29 | public static Output Invoke(GetRemoteReferenceInvokeArgs args, InvokeOutputOptions options) 30 | => global::Pulumi.Deployment.Instance.Invoke("terraform:state:getRemoteReference", args ?? new GetRemoteReferenceInvokeArgs(), options.WithDefaults()); 31 | } 32 | 33 | 34 | public sealed class GetRemoteReferenceArgs : global::Pulumi.InvokeArgs 35 | { 36 | /// 37 | /// The remote backend hostname to connect to. 38 | /// 39 | [Input("hostname")] 40 | public string? Hostname { get; set; } 41 | 42 | /// 43 | /// The name of the organization containing the targeted workspace(s). 44 | /// 45 | [Input("organization", required: true)] 46 | public string Organization { get; set; } = null!; 47 | 48 | [Input("token")] 49 | private string? _token; 50 | 51 | /// 52 | /// The token used to authenticate with the remote backend. 53 | /// 54 | public string? Token 55 | { 56 | get => _token; 57 | set => _token = value; 58 | } 59 | 60 | [Input("workspaces", required: true)] 61 | public Inputs.Workspaces Workspaces { get; set; } = null!; 62 | 63 | public GetRemoteReferenceArgs() 64 | { 65 | Hostname = "app.terraform.io"; 66 | } 67 | public static new GetRemoteReferenceArgs Empty => new GetRemoteReferenceArgs(); 68 | } 69 | 70 | public sealed class GetRemoteReferenceInvokeArgs : global::Pulumi.InvokeArgs 71 | { 72 | /// 73 | /// The remote backend hostname to connect to. 74 | /// 75 | [Input("hostname")] 76 | public Input? Hostname { get; set; } 77 | 78 | /// 79 | /// The name of the organization containing the targeted workspace(s). 80 | /// 81 | [Input("organization", required: true)] 82 | public Input Organization { get; set; } = null!; 83 | 84 | [Input("token")] 85 | private Input? _token; 86 | 87 | /// 88 | /// The token used to authenticate with the remote backend. 89 | /// 90 | public Input? Token 91 | { 92 | get => _token; 93 | set 94 | { 95 | var emptySecret = Output.CreateSecret(0); 96 | _token = Output.Tuple?, int>(value, emptySecret).Apply(t => t.Item1); 97 | } 98 | } 99 | 100 | [Input("workspaces", required: true)] 101 | public Input Workspaces { get; set; } = null!; 102 | 103 | public GetRemoteReferenceInvokeArgs() 104 | { 105 | Hostname = "app.terraform.io"; 106 | } 107 | public static new GetRemoteReferenceInvokeArgs Empty => new GetRemoteReferenceInvokeArgs(); 108 | } 109 | 110 | 111 | [OutputType] 112 | public sealed class GetRemoteReferenceResult 113 | { 114 | /// 115 | /// The outputs displayed from Terraform state. 116 | /// 117 | public readonly ImmutableDictionary Outputs; 118 | 119 | [OutputConstructor] 120 | private GetRemoteReferenceResult(ImmutableDictionary outputs) 121 | { 122 | Outputs = outputs; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /sdk/dotnet/State/Inputs/Workspaces.cs: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.Threading.Tasks; 8 | using Pulumi.Serialization; 9 | 10 | namespace Pulumi.Terraform.State.Inputs 11 | { 12 | 13 | public sealed class Workspaces : global::Pulumi.InvokeArgs 14 | { 15 | /// 16 | /// The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 17 | /// 18 | [Input("name")] 19 | public string? Name { get; set; } 20 | 21 | /// 22 | /// A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 23 | /// 24 | [Input("prefix")] 25 | public string? Prefix { get; set; } 26 | 27 | public Workspaces() 28 | { 29 | } 30 | public static new Workspaces Empty => new Workspaces(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sdk/dotnet/State/Inputs/WorkspacesArgs.cs: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.Threading.Tasks; 8 | using Pulumi.Serialization; 9 | 10 | namespace Pulumi.Terraform.State.Inputs 11 | { 12 | 13 | public sealed class WorkspacesArgs : global::Pulumi.ResourceArgs 14 | { 15 | /// 16 | /// The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 17 | /// 18 | [Input("name")] 19 | public Input? Name { get; set; } 20 | 21 | /// 22 | /// A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 23 | /// 24 | [Input("prefix")] 25 | public Input? Prefix { get; set; } 26 | 27 | public WorkspacesArgs() 28 | { 29 | } 30 | public static new WorkspacesArgs Empty => new WorkspacesArgs(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sdk/dotnet/State/README.md: -------------------------------------------------------------------------------- 1 | The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 2 | -------------------------------------------------------------------------------- /sdk/dotnet/Utilities.cs: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | namespace Pulumi.Terraform 5 | { 6 | static class Utilities 7 | { 8 | public static string? GetEnv(params string[] names) 9 | { 10 | foreach (var n in names) 11 | { 12 | var value = global::System.Environment.GetEnvironmentVariable(n); 13 | if (value != null) 14 | { 15 | return value; 16 | } 17 | } 18 | return null; 19 | } 20 | 21 | static string[] trueValues = { "1", "t", "T", "true", "TRUE", "True" }; 22 | static string[] falseValues = { "0", "f", "F", "false", "FALSE", "False" }; 23 | public static bool? GetEnvBoolean(params string[] names) 24 | { 25 | var s = GetEnv(names); 26 | if (s != null) 27 | { 28 | if (global::System.Array.IndexOf(trueValues, s) != -1) 29 | { 30 | return true; 31 | } 32 | if (global::System.Array.IndexOf(falseValues, s) != -1) 33 | { 34 | return false; 35 | } 36 | } 37 | return null; 38 | } 39 | 40 | public static int? GetEnvInt32(params string[] names) => int.TryParse(GetEnv(names), out int v) ? (int?)v : null; 41 | 42 | public static double? GetEnvDouble(params string[] names) => double.TryParse(GetEnv(names), out double v) ? (double?)v : null; 43 | 44 | [global::System.Obsolete("Please use WithDefaults instead")] 45 | public static global::Pulumi.InvokeOptions WithVersion(this global::Pulumi.InvokeOptions? options) 46 | { 47 | var dst = options ?? new global::Pulumi.InvokeOptions{}; 48 | dst.Version = options?.Version ?? Version; 49 | return dst; 50 | } 51 | 52 | public static global::Pulumi.InvokeOptions WithDefaults(this global::Pulumi.InvokeOptions? src) 53 | { 54 | var dst = src ?? new global::Pulumi.InvokeOptions{}; 55 | dst.Version = src?.Version ?? Version; 56 | return dst; 57 | } 58 | 59 | public static global::Pulumi.InvokeOutputOptions WithDefaults(this global::Pulumi.InvokeOutputOptions? src) 60 | { 61 | var dst = src ?? new global::Pulumi.InvokeOutputOptions{}; 62 | dst.Version = src?.Version ?? Version; 63 | return dst; 64 | } 65 | 66 | private readonly static string version; 67 | public static string Version => version; 68 | 69 | static Utilities() 70 | { 71 | var assembly = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Utilities)).Assembly; 72 | using var stream = assembly.GetManifestResourceStream("Pulumi.Terraform.version.txt"); 73 | using var reader = new global::System.IO.StreamReader(stream ?? throw new global::System.NotSupportedException("Missing embedded version.txt file")); 74 | version = reader.ReadToEnd().Trim(); 75 | var parts = version.Split("\n"); 76 | if (parts.Length == 2) 77 | { 78 | // The first part is the provider name. 79 | version = parts[1].Trim(); 80 | } 81 | } 82 | } 83 | 84 | internal sealed class TerraformResourceTypeAttribute : global::Pulumi.ResourceTypeAttribute 85 | { 86 | public TerraformResourceTypeAttribute(string type) : base(type, Utilities.Version) 87 | { 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /sdk/dotnet/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pulumi/pulumi-terraform/7aa5899413280c98b545daf2a84d402cbda6ece3/sdk/dotnet/logo.png -------------------------------------------------------------------------------- /sdk/dotnet/pulumi-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "resource": true, 3 | "name": "terraform", 4 | "version": "6.0.0-alpha.0+dev" 5 | } 6 | -------------------------------------------------------------------------------- /sdk/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pulumi/pulumi-terraform/sdk/v6 2 | 3 | go 1.22 4 | 5 | toolchain go1.24.0 6 | 7 | require ( 8 | github.com/blang/semver v3.5.1+incompatible 9 | github.com/pulumi/pulumi/sdk/v3 v3.160.0 10 | ) 11 | 12 | require ( 13 | dario.cat/mergo v1.0.0 // indirect 14 | github.com/BurntSushi/toml v1.2.1 // indirect 15 | github.com/Microsoft/go-winio v0.6.1 // indirect 16 | github.com/ProtonMail/go-crypto v1.1.3 // indirect 17 | github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect 18 | github.com/agext/levenshtein v1.2.3 // indirect 19 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect 20 | github.com/atotto/clipboard v0.1.4 // indirect 21 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 22 | github.com/charmbracelet/bubbles v0.16.1 // indirect 23 | github.com/charmbracelet/bubbletea v0.25.0 // indirect 24 | github.com/charmbracelet/lipgloss v0.7.1 // indirect 25 | github.com/cheggaaa/pb v1.0.29 // indirect 26 | github.com/cloudflare/circl v1.3.7 // indirect 27 | github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect 28 | github.com/cyphar/filepath-securejoin v0.3.6 // indirect 29 | github.com/djherbis/times v1.5.0 // indirect 30 | github.com/emirpasic/gods v1.18.1 // indirect 31 | github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect 32 | github.com/go-git/go-billy/v5 v5.6.1 // indirect 33 | github.com/go-git/go-git/v5 v5.13.1 // indirect 34 | github.com/gogo/protobuf v1.3.2 // indirect 35 | github.com/golang/glog v1.2.4 // indirect 36 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 37 | github.com/google/uuid v1.6.0 // indirect 38 | github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect 39 | github.com/hashicorp/errwrap v1.1.0 // indirect 40 | github.com/hashicorp/go-multierror v1.1.1 // indirect 41 | github.com/hashicorp/hcl/v2 v2.17.0 // indirect 42 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 43 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect 44 | github.com/kevinburke/ssh_config v1.2.0 // indirect 45 | github.com/lucasb-eyer/go-colorful v1.2.0 // indirect 46 | github.com/mattn/go-isatty v0.0.19 // indirect 47 | github.com/mattn/go-localereader v0.0.1 // indirect 48 | github.com/mattn/go-runewidth v0.0.15 // indirect 49 | github.com/mitchellh/go-ps v1.0.0 // indirect 50 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect 51 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect 52 | github.com/muesli/cancelreader v0.2.2 // indirect 53 | github.com/muesli/reflow v0.3.0 // indirect 54 | github.com/muesli/termenv v0.15.2 // indirect 55 | github.com/opentracing/basictracer-go v1.1.0 // indirect 56 | github.com/opentracing/opentracing-go v1.2.0 // indirect 57 | github.com/pgavlin/fx v0.1.6 // indirect 58 | github.com/pjbgf/sha1cd v0.3.0 // indirect 59 | github.com/pkg/errors v0.9.1 // indirect 60 | github.com/pkg/term v1.1.0 // indirect 61 | github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect 62 | github.com/pulumi/esc v0.9.1 // indirect 63 | github.com/rivo/uniseg v0.4.4 // indirect 64 | github.com/rogpeppe/go-internal v1.12.0 // indirect 65 | github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect 66 | github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect 67 | github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect 68 | github.com/skeema/knownhosts v1.3.0 // indirect 69 | github.com/spf13/cobra v1.7.0 // indirect 70 | github.com/spf13/pflag v1.0.5 // indirect 71 | github.com/stretchr/objx v0.5.2 // indirect 72 | github.com/texttheater/golang-levenshtein v1.0.1 // indirect 73 | github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect 74 | github.com/uber/jaeger-lib v2.4.1+incompatible // indirect 75 | github.com/xanzy/ssh-agent v0.3.3 // indirect 76 | github.com/zclconf/go-cty v1.13.2 // indirect 77 | go.uber.org/atomic v1.9.0 // indirect 78 | golang.org/x/crypto v0.33.0 // indirect 79 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect 80 | golang.org/x/mod v0.19.0 // indirect 81 | golang.org/x/net v0.35.0 // indirect 82 | golang.org/x/sync v0.11.0 // indirect 83 | golang.org/x/sys v0.30.0 // indirect 84 | golang.org/x/term v0.29.0 // indirect 85 | golang.org/x/text v0.22.0 // indirect 86 | golang.org/x/tools v0.23.0 // indirect 87 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect 88 | google.golang.org/grpc v1.63.2 // indirect 89 | google.golang.org/protobuf v1.33.0 // indirect 90 | gopkg.in/warnings.v0 v0.1.2 // indirect 91 | gopkg.in/yaml.v3 v3.0.1 // indirect 92 | lukechampine.com/frand v1.4.2 // indirect 93 | ) 94 | -------------------------------------------------------------------------------- /sdk/go/terraform/doc.go: -------------------------------------------------------------------------------- 1 | // The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 2 | package terraform 3 | -------------------------------------------------------------------------------- /sdk/go/terraform/init.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package terraform 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/blang/semver" 10 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/internal" 11 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 | ) 13 | 14 | type pkg struct { 15 | version semver.Version 16 | } 17 | 18 | func (p *pkg) Version() semver.Version { 19 | return p.version 20 | } 21 | 22 | func (p *pkg) ConstructProvider(ctx *pulumi.Context, name, typ, urn string) (pulumi.ProviderResource, error) { 23 | if typ != "pulumi:providers:terraform" { 24 | return nil, fmt.Errorf("unknown provider type: %s", typ) 25 | } 26 | 27 | r := &Provider{} 28 | err := ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn)) 29 | return r, err 30 | } 31 | 32 | func init() { 33 | version, err := internal.PkgVersion() 34 | if err != nil { 35 | version = semver.Version{Major: 1} 36 | } 37 | pulumi.RegisterResourcePackage( 38 | "terraform", 39 | &pkg{version}, 40 | ) 41 | } 42 | -------------------------------------------------------------------------------- /sdk/go/terraform/internal/pulumiUtilities.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package internal 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "reflect" 10 | "regexp" 11 | "strconv" 12 | "strings" 13 | 14 | "github.com/blang/semver" 15 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 16 | ) 17 | 18 | import ( 19 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi/internals" 20 | ) 21 | 22 | type envParser func(v string) interface{} 23 | 24 | func ParseEnvBool(v string) interface{} { 25 | b, err := strconv.ParseBool(v) 26 | if err != nil { 27 | return nil 28 | } 29 | return b 30 | } 31 | 32 | func ParseEnvInt(v string) interface{} { 33 | i, err := strconv.ParseInt(v, 0, 0) 34 | if err != nil { 35 | return nil 36 | } 37 | return int(i) 38 | } 39 | 40 | func ParseEnvFloat(v string) interface{} { 41 | f, err := strconv.ParseFloat(v, 64) 42 | if err != nil { 43 | return nil 44 | } 45 | return f 46 | } 47 | 48 | func ParseEnvStringArray(v string) interface{} { 49 | var result pulumi.StringArray 50 | for _, item := range strings.Split(v, ";") { 51 | result = append(result, pulumi.String(item)) 52 | } 53 | return result 54 | } 55 | 56 | func GetEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} { 57 | for _, v := range vars { 58 | if value, ok := os.LookupEnv(v); ok { 59 | if parser != nil { 60 | return parser(value) 61 | } 62 | return value 63 | } 64 | } 65 | return def 66 | } 67 | 68 | // PkgVersion uses reflection to determine the version of the current package. 69 | // If a version cannot be determined, v1 will be assumed. The second return 70 | // value is always nil. 71 | func PkgVersion() (semver.Version, error) { 72 | // emptyVersion defaults to v0.0.0 73 | if !SdkVersion.Equals(semver.Version{}) { 74 | return SdkVersion, nil 75 | } 76 | type sentinal struct{} 77 | pkgPath := reflect.TypeOf(sentinal{}).PkgPath() 78 | re := regexp.MustCompile("^.*/pulumi-terraform/sdk(/v\\d+)?") 79 | if match := re.FindStringSubmatch(pkgPath); match != nil { 80 | vStr := match[1] 81 | if len(vStr) == 0 { // If the version capture group was empty, default to v1. 82 | return semver.Version{Major: 1}, nil 83 | } 84 | return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil 85 | } 86 | return semver.Version{Major: 1}, nil 87 | } 88 | 89 | // isZero is a null safe check for if a value is it's types zero value. 90 | func IsZero(v interface{}) bool { 91 | if v == nil { 92 | return true 93 | } 94 | return reflect.ValueOf(v).IsZero() 95 | } 96 | 97 | func CallPlain( 98 | ctx *pulumi.Context, 99 | tok string, 100 | args pulumi.Input, 101 | output pulumi.Output, 102 | self pulumi.Resource, 103 | property string, 104 | resultPtr reflect.Value, 105 | errorPtr *error, 106 | opts ...pulumi.InvokeOption, 107 | ) { 108 | res, err := callPlainInner(ctx, tok, args, output, self, opts...) 109 | if err != nil { 110 | *errorPtr = err 111 | return 112 | } 113 | 114 | v := reflect.ValueOf(res) 115 | 116 | // extract res.property field if asked to do so 117 | if property != "" { 118 | v = v.FieldByName("Res") 119 | } 120 | 121 | // return by setting the result pointer; this style of returns shortens the generated code without generics 122 | resultPtr.Elem().Set(v) 123 | } 124 | 125 | func callPlainInner( 126 | ctx *pulumi.Context, 127 | tok string, 128 | args pulumi.Input, 129 | output pulumi.Output, 130 | self pulumi.Resource, 131 | opts ...pulumi.InvokeOption, 132 | ) (any, error) { 133 | o, err := ctx.Call(tok, args, output, self, opts...) 134 | if err != nil { 135 | return nil, err 136 | } 137 | 138 | outputData, err := internals.UnsafeAwaitOutput(ctx.Context(), o) 139 | if err != nil { 140 | return nil, err 141 | } 142 | 143 | // Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency. 144 | known := outputData.Known 145 | value := outputData.Value 146 | secret := outputData.Secret 147 | 148 | problem := "" 149 | if !known { 150 | problem = "an unknown value" 151 | } else if secret { 152 | problem = "a secret value" 153 | } 154 | 155 | if problem != "" { 156 | return nil, fmt.Errorf("Plain resource method %q incorrectly returned %s. "+ 157 | "This is an error in the provider, please report this to the provider developer.", 158 | tok, problem) 159 | } 160 | 161 | return value, nil 162 | } 163 | 164 | // PkgResourceDefaultOpts provides package level defaults to pulumi.OptionResource. 165 | func PkgResourceDefaultOpts(opts []pulumi.ResourceOption) []pulumi.ResourceOption { 166 | defaults := []pulumi.ResourceOption{} 167 | 168 | version := semver.MustParse("6.0.0-alpha.0+dev") 169 | if !version.Equals(semver.Version{}) { 170 | defaults = append(defaults, pulumi.Version(version.String())) 171 | } 172 | return append(defaults, opts...) 173 | } 174 | 175 | // PkgInvokeDefaultOpts provides package level defaults to pulumi.OptionInvoke. 176 | func PkgInvokeDefaultOpts(opts []pulumi.InvokeOption) []pulumi.InvokeOption { 177 | defaults := []pulumi.InvokeOption{} 178 | 179 | version := semver.MustParse("6.0.0-alpha.0+dev") 180 | if !version.Equals(semver.Version{}) { 181 | defaults = append(defaults, pulumi.Version(version.String())) 182 | } 183 | return append(defaults, opts...) 184 | } 185 | -------------------------------------------------------------------------------- /sdk/go/terraform/internal/pulumiVersion.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package internal 5 | 6 | import ( 7 | "github.com/blang/semver" 8 | ) 9 | 10 | var SdkVersion semver.Version = semver.Version{} 11 | var pluginDownloadURL string = "" 12 | -------------------------------------------------------------------------------- /sdk/go/terraform/provider.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package terraform 5 | 6 | import ( 7 | "context" 8 | "reflect" 9 | 10 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/internal" 11 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 | ) 13 | 14 | type Provider struct { 15 | pulumi.ProviderResourceState 16 | } 17 | 18 | // NewProvider registers a new resource with the given unique name, arguments, and options. 19 | func NewProvider(ctx *pulumi.Context, 20 | name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) { 21 | if args == nil { 22 | args = &ProviderArgs{} 23 | } 24 | 25 | opts = internal.PkgResourceDefaultOpts(opts) 26 | var resource Provider 27 | err := ctx.RegisterResource("pulumi:providers:terraform", name, args, &resource, opts...) 28 | if err != nil { 29 | return nil, err 30 | } 31 | return &resource, nil 32 | } 33 | 34 | type providerArgs struct { 35 | } 36 | 37 | // The set of arguments for constructing a Provider resource. 38 | type ProviderArgs struct { 39 | } 40 | 41 | func (ProviderArgs) ElementType() reflect.Type { 42 | return reflect.TypeOf((*providerArgs)(nil)).Elem() 43 | } 44 | 45 | type ProviderInput interface { 46 | pulumi.Input 47 | 48 | ToProviderOutput() ProviderOutput 49 | ToProviderOutputWithContext(ctx context.Context) ProviderOutput 50 | } 51 | 52 | func (*Provider) ElementType() reflect.Type { 53 | return reflect.TypeOf((**Provider)(nil)).Elem() 54 | } 55 | 56 | func (i *Provider) ToProviderOutput() ProviderOutput { 57 | return i.ToProviderOutputWithContext(context.Background()) 58 | } 59 | 60 | func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput { 61 | return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput) 62 | } 63 | 64 | type ProviderOutput struct{ *pulumi.OutputState } 65 | 66 | func (ProviderOutput) ElementType() reflect.Type { 67 | return reflect.TypeOf((**Provider)(nil)).Elem() 68 | } 69 | 70 | func (o ProviderOutput) ToProviderOutput() ProviderOutput { 71 | return o 72 | } 73 | 74 | func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) ProviderOutput { 75 | return o 76 | } 77 | 78 | func init() { 79 | pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{}) 80 | pulumi.RegisterOutputType(ProviderOutput{}) 81 | } 82 | -------------------------------------------------------------------------------- /sdk/go/terraform/pulumi-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "resource": true, 3 | "name": "terraform", 4 | "version": "6.0.0-alpha.0+dev" 5 | } 6 | -------------------------------------------------------------------------------- /sdk/go/terraform/state/getLocalReference.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package state 5 | 6 | import ( 7 | "context" 8 | "reflect" 9 | 10 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/internal" 11 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 | ) 13 | 14 | // Access state from the local filesystem. 15 | func GetLocalReference(ctx *pulumi.Context, args *GetLocalReferenceArgs, opts ...pulumi.InvokeOption) (*GetLocalReferenceResult, error) { 16 | opts = internal.PkgInvokeDefaultOpts(opts) 17 | var rv GetLocalReferenceResult 18 | err := ctx.Invoke("terraform:state:getLocalReference", args, &rv, opts...) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return &rv, nil 23 | } 24 | 25 | type GetLocalReferenceArgs struct { 26 | // The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 27 | Path *string `pulumi:"path"` 28 | // The path to non-default workspaces. 29 | WorkspaceDir *string `pulumi:"workspaceDir"` 30 | } 31 | 32 | // The result of fetching from a Terraform state store. 33 | type GetLocalReferenceResult struct { 34 | // The outputs displayed from Terraform state. 35 | Outputs map[string]interface{} `pulumi:"outputs"` 36 | } 37 | 38 | func GetLocalReferenceOutput(ctx *pulumi.Context, args GetLocalReferenceOutputArgs, opts ...pulumi.InvokeOption) GetLocalReferenceResultOutput { 39 | return pulumi.ToOutputWithContext(ctx.Context(), args). 40 | ApplyT(func(v interface{}) (GetLocalReferenceResultOutput, error) { 41 | args := v.(GetLocalReferenceArgs) 42 | options := pulumi.InvokeOutputOptions{InvokeOptions: internal.PkgInvokeDefaultOpts(opts)} 43 | return ctx.InvokeOutput("terraform:state:getLocalReference", args, GetLocalReferenceResultOutput{}, options).(GetLocalReferenceResultOutput), nil 44 | }).(GetLocalReferenceResultOutput) 45 | } 46 | 47 | type GetLocalReferenceOutputArgs struct { 48 | // The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 49 | Path pulumi.StringPtrInput `pulumi:"path"` 50 | // The path to non-default workspaces. 51 | WorkspaceDir pulumi.StringPtrInput `pulumi:"workspaceDir"` 52 | } 53 | 54 | func (GetLocalReferenceOutputArgs) ElementType() reflect.Type { 55 | return reflect.TypeOf((*GetLocalReferenceArgs)(nil)).Elem() 56 | } 57 | 58 | // The result of fetching from a Terraform state store. 59 | type GetLocalReferenceResultOutput struct{ *pulumi.OutputState } 60 | 61 | func (GetLocalReferenceResultOutput) ElementType() reflect.Type { 62 | return reflect.TypeOf((*GetLocalReferenceResult)(nil)).Elem() 63 | } 64 | 65 | func (o GetLocalReferenceResultOutput) ToGetLocalReferenceResultOutput() GetLocalReferenceResultOutput { 66 | return o 67 | } 68 | 69 | func (o GetLocalReferenceResultOutput) ToGetLocalReferenceResultOutputWithContext(ctx context.Context) GetLocalReferenceResultOutput { 70 | return o 71 | } 72 | 73 | // The outputs displayed from Terraform state. 74 | func (o GetLocalReferenceResultOutput) Outputs() pulumi.MapOutput { 75 | return o.ApplyT(func(v GetLocalReferenceResult) map[string]interface{} { return v.Outputs }).(pulumi.MapOutput) 76 | } 77 | 78 | func init() { 79 | pulumi.RegisterOutputType(GetLocalReferenceResultOutput{}) 80 | } 81 | -------------------------------------------------------------------------------- /sdk/go/terraform/state/getRemoteReference.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package state 5 | 6 | import ( 7 | "context" 8 | "reflect" 9 | 10 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/internal" 11 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 | ) 13 | 14 | // Access state from a remote backend. 15 | func GetRemoteReference(ctx *pulumi.Context, args *GetRemoteReferenceArgs, opts ...pulumi.InvokeOption) (*GetRemoteReferenceResult, error) { 16 | opts = internal.PkgInvokeDefaultOpts(opts) 17 | var rv GetRemoteReferenceResult 18 | err := ctx.Invoke("terraform:state:getRemoteReference", args.Defaults(), &rv, opts...) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return &rv, nil 23 | } 24 | 25 | type GetRemoteReferenceArgs struct { 26 | // The remote backend hostname to connect to. 27 | Hostname *string `pulumi:"hostname"` 28 | // The name of the organization containing the targeted workspace(s). 29 | Organization string `pulumi:"organization"` 30 | // The token used to authenticate with the remote backend. 31 | Token *string `pulumi:"token"` 32 | Workspaces Workspaces `pulumi:"workspaces"` 33 | } 34 | 35 | // Defaults sets the appropriate defaults for GetRemoteReferenceArgs 36 | func (val *GetRemoteReferenceArgs) Defaults() *GetRemoteReferenceArgs { 37 | if val == nil { 38 | return nil 39 | } 40 | tmp := *val 41 | if tmp.Hostname == nil { 42 | hostname_ := "app.terraform.io" 43 | tmp.Hostname = &hostname_ 44 | } 45 | return &tmp 46 | } 47 | 48 | // The result of fetching from a Terraform state store. 49 | type GetRemoteReferenceResult struct { 50 | // The outputs displayed from Terraform state. 51 | Outputs map[string]interface{} `pulumi:"outputs"` 52 | } 53 | 54 | func GetRemoteReferenceOutput(ctx *pulumi.Context, args GetRemoteReferenceOutputArgs, opts ...pulumi.InvokeOption) GetRemoteReferenceResultOutput { 55 | return pulumi.ToOutputWithContext(ctx.Context(), args). 56 | ApplyT(func(v interface{}) (GetRemoteReferenceResultOutput, error) { 57 | args := v.(GetRemoteReferenceArgs) 58 | options := pulumi.InvokeOutputOptions{InvokeOptions: internal.PkgInvokeDefaultOpts(opts)} 59 | return ctx.InvokeOutput("terraform:state:getRemoteReference", args.Defaults(), GetRemoteReferenceResultOutput{}, options).(GetRemoteReferenceResultOutput), nil 60 | }).(GetRemoteReferenceResultOutput) 61 | } 62 | 63 | type GetRemoteReferenceOutputArgs struct { 64 | // The remote backend hostname to connect to. 65 | Hostname pulumi.StringPtrInput `pulumi:"hostname"` 66 | // The name of the organization containing the targeted workspace(s). 67 | Organization pulumi.StringInput `pulumi:"organization"` 68 | // The token used to authenticate with the remote backend. 69 | Token pulumi.StringPtrInput `pulumi:"token"` 70 | Workspaces WorkspacesInput `pulumi:"workspaces"` 71 | } 72 | 73 | func (GetRemoteReferenceOutputArgs) ElementType() reflect.Type { 74 | return reflect.TypeOf((*GetRemoteReferenceArgs)(nil)).Elem() 75 | } 76 | 77 | // The result of fetching from a Terraform state store. 78 | type GetRemoteReferenceResultOutput struct{ *pulumi.OutputState } 79 | 80 | func (GetRemoteReferenceResultOutput) ElementType() reflect.Type { 81 | return reflect.TypeOf((*GetRemoteReferenceResult)(nil)).Elem() 82 | } 83 | 84 | func (o GetRemoteReferenceResultOutput) ToGetRemoteReferenceResultOutput() GetRemoteReferenceResultOutput { 85 | return o 86 | } 87 | 88 | func (o GetRemoteReferenceResultOutput) ToGetRemoteReferenceResultOutputWithContext(ctx context.Context) GetRemoteReferenceResultOutput { 89 | return o 90 | } 91 | 92 | // The outputs displayed from Terraform state. 93 | func (o GetRemoteReferenceResultOutput) Outputs() pulumi.MapOutput { 94 | return o.ApplyT(func(v GetRemoteReferenceResult) map[string]interface{} { return v.Outputs }).(pulumi.MapOutput) 95 | } 96 | 97 | func init() { 98 | pulumi.RegisterOutputType(GetRemoteReferenceResultOutput{}) 99 | } 100 | -------------------------------------------------------------------------------- /sdk/go/terraform/state/pulumiTypes.go: -------------------------------------------------------------------------------- 1 | // Code generated by pulumi-language-go DO NOT EDIT. 2 | // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package state 5 | 6 | import ( 7 | "context" 8 | "reflect" 9 | 10 | "github.com/pulumi/pulumi-terraform/sdk/v6/go/terraform/internal" 11 | "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 | ) 13 | 14 | var _ = internal.GetEnvOrDefault 15 | 16 | type Workspaces struct { 17 | // The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 18 | Name *string `pulumi:"name"` 19 | // A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 20 | Prefix *string `pulumi:"prefix"` 21 | } 22 | 23 | // WorkspacesInput is an input type that accepts WorkspacesArgs and WorkspacesOutput values. 24 | // You can construct a concrete instance of `WorkspacesInput` via: 25 | // 26 | // WorkspacesArgs{...} 27 | type WorkspacesInput interface { 28 | pulumi.Input 29 | 30 | ToWorkspacesOutput() WorkspacesOutput 31 | ToWorkspacesOutputWithContext(context.Context) WorkspacesOutput 32 | } 33 | 34 | type WorkspacesArgs struct { 35 | // The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 36 | Name pulumi.StringPtrInput `pulumi:"name"` 37 | // A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 38 | Prefix pulumi.StringPtrInput `pulumi:"prefix"` 39 | } 40 | 41 | func (WorkspacesArgs) ElementType() reflect.Type { 42 | return reflect.TypeOf((*Workspaces)(nil)).Elem() 43 | } 44 | 45 | func (i WorkspacesArgs) ToWorkspacesOutput() WorkspacesOutput { 46 | return i.ToWorkspacesOutputWithContext(context.Background()) 47 | } 48 | 49 | func (i WorkspacesArgs) ToWorkspacesOutputWithContext(ctx context.Context) WorkspacesOutput { 50 | return pulumi.ToOutputWithContext(ctx, i).(WorkspacesOutput) 51 | } 52 | 53 | type WorkspacesOutput struct{ *pulumi.OutputState } 54 | 55 | func (WorkspacesOutput) ElementType() reflect.Type { 56 | return reflect.TypeOf((*Workspaces)(nil)).Elem() 57 | } 58 | 59 | func (o WorkspacesOutput) ToWorkspacesOutput() WorkspacesOutput { 60 | return o 61 | } 62 | 63 | func (o WorkspacesOutput) ToWorkspacesOutputWithContext(ctx context.Context) WorkspacesOutput { 64 | return o 65 | } 66 | 67 | // The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 68 | func (o WorkspacesOutput) Name() pulumi.StringPtrOutput { 69 | return o.ApplyT(func(v Workspaces) *string { return v.Name }).(pulumi.StringPtrOutput) 70 | } 71 | 72 | // A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 73 | func (o WorkspacesOutput) Prefix() pulumi.StringPtrOutput { 74 | return o.ApplyT(func(v Workspaces) *string { return v.Prefix }).(pulumi.StringPtrOutput) 75 | } 76 | 77 | func init() { 78 | pulumi.RegisterInputType(reflect.TypeOf((*WorkspacesInput)(nil)).Elem(), WorkspacesArgs{}) 79 | pulumi.RegisterOutputType(WorkspacesOutput{}) 80 | } 81 | -------------------------------------------------------------------------------- /sdk/java/README.md: -------------------------------------------------------------------------------- 1 | The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 2 | -------------------------------------------------------------------------------- /sdk/java/settings.gradle: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-java-gen. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | pluginManagement { 5 | repositories { 6 | maven { // The google mirror is less flaky than mavenCentral() 7 | url("https://maven-central.storage-download.googleapis.com/maven2/") 8 | } 9 | gradlePluginPortal() 10 | } 11 | } 12 | 13 | rootProject.name = "com.pulumi.terraform" 14 | include("lib") 15 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/Provider.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform; 5 | 6 | import com.pulumi.core.Output; 7 | import com.pulumi.core.annotations.ResourceType; 8 | import com.pulumi.core.internal.Codegen; 9 | import com.pulumi.terraform.ProviderArgs; 10 | import com.pulumi.terraform.Utilities; 11 | import javax.annotation.Nullable; 12 | 13 | @ResourceType(type="pulumi:providers:terraform") 14 | public class Provider extends com.pulumi.resources.ProviderResource { 15 | /** 16 | * 17 | * @param name The _unique_ name of the resulting resource. 18 | */ 19 | public Provider(java.lang.String name) { 20 | this(name, ProviderArgs.Empty); 21 | } 22 | /** 23 | * 24 | * @param name The _unique_ name of the resulting resource. 25 | * @param args The arguments to use to populate this resource's properties. 26 | */ 27 | public Provider(java.lang.String name, @Nullable ProviderArgs args) { 28 | this(name, args, null); 29 | } 30 | /** 31 | * 32 | * @param name The _unique_ name of the resulting resource. 33 | * @param args The arguments to use to populate this resource's properties. 34 | * @param options A bag of options that control this resource's behavior. 35 | */ 36 | public Provider(java.lang.String name, @Nullable ProviderArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { 37 | super("terraform", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); 38 | } 39 | 40 | private static ProviderArgs makeArgs(@Nullable ProviderArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { 41 | if (options != null && options.getUrn().isPresent()) { 42 | return null; 43 | } 44 | return args == null ? ProviderArgs.Empty : args; 45 | } 46 | 47 | private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { 48 | var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() 49 | .version(Utilities.getVersion()) 50 | .build(); 51 | return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/ProviderArgs.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform; 5 | 6 | 7 | 8 | 9 | public final class ProviderArgs extends com.pulumi.resources.ResourceArgs { 10 | 11 | public static final ProviderArgs Empty = new ProviderArgs(); 12 | 13 | public static Builder builder() { 14 | return new Builder(); 15 | } 16 | 17 | public static final class Builder { 18 | private ProviderArgs $; 19 | 20 | public Builder() { 21 | $ = new ProviderArgs(); 22 | } 23 | public ProviderArgs build() { 24 | return $; 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/Utilities.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform; 5 | 6 | 7 | 8 | 9 | 10 | import java.io.BufferedReader; 11 | import java.io.InputStreamReader; 12 | import java.util.Optional; 13 | import java.util.stream.Collectors; 14 | import javax.annotation.Nullable; 15 | import com.pulumi.core.internal.Environment; 16 | import com.pulumi.deployment.InvokeOptions; 17 | import com.pulumi.deployment.InvokeOutputOptions; 18 | 19 | public class Utilities { 20 | 21 | public static Optional getEnv(java.lang.String... names) { 22 | for (var n : names) { 23 | var value = Environment.getEnvironmentVariable(n); 24 | if (value.isValue()) { 25 | return Optional.of(value.value()); 26 | } 27 | } 28 | return Optional.empty(); 29 | } 30 | 31 | public static Optional getEnvBoolean(java.lang.String... names) { 32 | for (var n : names) { 33 | var value = Environment.getBooleanEnvironmentVariable(n); 34 | if (value.isValue()) { 35 | return Optional.of(value.value()); 36 | } 37 | } 38 | return Optional.empty(); 39 | } 40 | 41 | public static Optional getEnvInteger(java.lang.String... names) { 42 | for (var n : names) { 43 | var value = Environment.getIntegerEnvironmentVariable(n); 44 | if (value.isValue()) { 45 | return Optional.of(value.value()); 46 | } 47 | } 48 | return Optional.empty(); 49 | } 50 | 51 | public static Optional getEnvDouble(java.lang.String... names) { 52 | for (var n : names) { 53 | var value = Environment.getDoubleEnvironmentVariable(n); 54 | if (value.isValue()) { 55 | return Optional.of(value.value()); 56 | } 57 | } 58 | return Optional.empty(); 59 | } 60 | 61 | public static InvokeOptions withVersion(@Nullable InvokeOptions options) { 62 | if (options != null && options.getVersion().isPresent()) { 63 | return options; 64 | } 65 | return new InvokeOptions( 66 | options == null ? null : options.getParent().orElse(null), 67 | options == null ? null : options.getProvider().orElse(null), 68 | getVersion() 69 | ); 70 | } 71 | 72 | public static InvokeOutputOptions withVersion(@Nullable InvokeOutputOptions options) { 73 | if (options != null && options.getVersion().isPresent()) { 74 | return options; 75 | } 76 | return new InvokeOutputOptions( 77 | options == null ? null : options.getParent().orElse(null), 78 | options == null ? null : options.getProvider().orElse(null), 79 | getVersion(), 80 | options == null ? null : options.getDependsOn() 81 | ); 82 | } 83 | 84 | private static final java.lang.String version; 85 | public static java.lang.String getVersion() { 86 | return version; 87 | } 88 | 89 | static { 90 | var resourceName = "com/pulumi/terraform/version.txt"; 91 | var versionFile = Utilities.class.getClassLoader().getResourceAsStream(resourceName); 92 | if (versionFile == null) { 93 | throw new IllegalStateException( 94 | java.lang.String.format("expected resource '%s' on Classpath, not found", resourceName) 95 | ); 96 | } 97 | version = new BufferedReader(new InputStreamReader(versionFile)) 98 | .lines() 99 | .collect(Collectors.joining("\n")) 100 | .trim(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/StateFunctions.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state; 5 | 6 | import com.pulumi.core.Output; 7 | import com.pulumi.core.TypeShape; 8 | import com.pulumi.deployment.Deployment; 9 | import com.pulumi.deployment.InvokeOptions; 10 | import com.pulumi.deployment.InvokeOutputOptions; 11 | import com.pulumi.terraform.Utilities; 12 | import com.pulumi.terraform.state.inputs.GetLocalReferenceArgs; 13 | import com.pulumi.terraform.state.inputs.GetLocalReferencePlainArgs; 14 | import com.pulumi.terraform.state.inputs.GetRemoteReferenceArgs; 15 | import com.pulumi.terraform.state.inputs.GetRemoteReferencePlainArgs; 16 | import com.pulumi.terraform.state.outputs.GetLocalReferenceResult; 17 | import com.pulumi.terraform.state.outputs.GetRemoteReferenceResult; 18 | import java.util.concurrent.CompletableFuture; 19 | 20 | public final class StateFunctions { 21 | /** 22 | * Access state from the local filesystem. 23 | * 24 | */ 25 | public static Output getLocalReference() { 26 | return getLocalReference(GetLocalReferenceArgs.Empty, InvokeOptions.Empty); 27 | } 28 | /** 29 | * Access state from the local filesystem. 30 | * 31 | */ 32 | public static CompletableFuture getLocalReferencePlain() { 33 | return getLocalReferencePlain(GetLocalReferencePlainArgs.Empty, InvokeOptions.Empty); 34 | } 35 | /** 36 | * Access state from the local filesystem. 37 | * 38 | */ 39 | public static Output getLocalReference(GetLocalReferenceArgs args) { 40 | return getLocalReference(args, InvokeOptions.Empty); 41 | } 42 | /** 43 | * Access state from the local filesystem. 44 | * 45 | */ 46 | public static CompletableFuture getLocalReferencePlain(GetLocalReferencePlainArgs args) { 47 | return getLocalReferencePlain(args, InvokeOptions.Empty); 48 | } 49 | /** 50 | * Access state from the local filesystem. 51 | * 52 | */ 53 | public static Output getLocalReference(GetLocalReferenceArgs args, InvokeOptions options) { 54 | return Deployment.getInstance().invoke("terraform:state:getLocalReference", TypeShape.of(GetLocalReferenceResult.class), args, Utilities.withVersion(options)); 55 | } 56 | /** 57 | * Access state from the local filesystem. 58 | * 59 | */ 60 | public static Output getLocalReference(GetLocalReferenceArgs args, InvokeOutputOptions options) { 61 | return Deployment.getInstance().invoke("terraform:state:getLocalReference", TypeShape.of(GetLocalReferenceResult.class), args, Utilities.withVersion(options)); 62 | } 63 | /** 64 | * Access state from the local filesystem. 65 | * 66 | */ 67 | public static CompletableFuture getLocalReferencePlain(GetLocalReferencePlainArgs args, InvokeOptions options) { 68 | return Deployment.getInstance().invokeAsync("terraform:state:getLocalReference", TypeShape.of(GetLocalReferenceResult.class), args, Utilities.withVersion(options)); 69 | } 70 | /** 71 | * Access state from a remote backend. 72 | * 73 | */ 74 | public static Output getRemoteReference(GetRemoteReferenceArgs args) { 75 | return getRemoteReference(args, InvokeOptions.Empty); 76 | } 77 | /** 78 | * Access state from a remote backend. 79 | * 80 | */ 81 | public static CompletableFuture getRemoteReferencePlain(GetRemoteReferencePlainArgs args) { 82 | return getRemoteReferencePlain(args, InvokeOptions.Empty); 83 | } 84 | /** 85 | * Access state from a remote backend. 86 | * 87 | */ 88 | public static Output getRemoteReference(GetRemoteReferenceArgs args, InvokeOptions options) { 89 | return Deployment.getInstance().invoke("terraform:state:getRemoteReference", TypeShape.of(GetRemoteReferenceResult.class), args, Utilities.withVersion(options)); 90 | } 91 | /** 92 | * Access state from a remote backend. 93 | * 94 | */ 95 | public static Output getRemoteReference(GetRemoteReferenceArgs args, InvokeOutputOptions options) { 96 | return Deployment.getInstance().invoke("terraform:state:getRemoteReference", TypeShape.of(GetRemoteReferenceResult.class), args, Utilities.withVersion(options)); 97 | } 98 | /** 99 | * Access state from a remote backend. 100 | * 101 | */ 102 | public static CompletableFuture getRemoteReferencePlain(GetRemoteReferencePlainArgs args, InvokeOptions options) { 103 | return Deployment.getInstance().invokeAsync("terraform:state:getRemoteReference", TypeShape.of(GetRemoteReferenceResult.class), args, Utilities.withVersion(options)); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/inputs/GetLocalReferenceArgs.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.inputs; 5 | 6 | import com.pulumi.core.Output; 7 | import com.pulumi.core.annotations.Import; 8 | import java.lang.String; 9 | import java.util.Objects; 10 | import java.util.Optional; 11 | import javax.annotation.Nullable; 12 | 13 | 14 | public final class GetLocalReferenceArgs extends com.pulumi.resources.InvokeArgs { 15 | 16 | public static final GetLocalReferenceArgs Empty = new GetLocalReferenceArgs(); 17 | 18 | /** 19 | * The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 20 | * 21 | */ 22 | @Import(name="path") 23 | private @Nullable Output path; 24 | 25 | /** 26 | * @return The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 27 | * 28 | */ 29 | public Optional> path() { 30 | return Optional.ofNullable(this.path); 31 | } 32 | 33 | /** 34 | * The path to non-default workspaces. 35 | * 36 | */ 37 | @Import(name="workspaceDir") 38 | private @Nullable Output workspaceDir; 39 | 40 | /** 41 | * @return The path to non-default workspaces. 42 | * 43 | */ 44 | public Optional> workspaceDir() { 45 | return Optional.ofNullable(this.workspaceDir); 46 | } 47 | 48 | private GetLocalReferenceArgs() {} 49 | 50 | private GetLocalReferenceArgs(GetLocalReferenceArgs $) { 51 | this.path = $.path; 52 | this.workspaceDir = $.workspaceDir; 53 | } 54 | 55 | public static Builder builder() { 56 | return new Builder(); 57 | } 58 | public static Builder builder(GetLocalReferenceArgs defaults) { 59 | return new Builder(defaults); 60 | } 61 | 62 | public static final class Builder { 63 | private GetLocalReferenceArgs $; 64 | 65 | public Builder() { 66 | $ = new GetLocalReferenceArgs(); 67 | } 68 | 69 | public Builder(GetLocalReferenceArgs defaults) { 70 | $ = new GetLocalReferenceArgs(Objects.requireNonNull(defaults)); 71 | } 72 | 73 | /** 74 | * @param path The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 75 | * 76 | * @return builder 77 | * 78 | */ 79 | public Builder path(@Nullable Output path) { 80 | $.path = path; 81 | return this; 82 | } 83 | 84 | /** 85 | * @param path The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 86 | * 87 | * @return builder 88 | * 89 | */ 90 | public Builder path(String path) { 91 | return path(Output.of(path)); 92 | } 93 | 94 | /** 95 | * @param workspaceDir The path to non-default workspaces. 96 | * 97 | * @return builder 98 | * 99 | */ 100 | public Builder workspaceDir(@Nullable Output workspaceDir) { 101 | $.workspaceDir = workspaceDir; 102 | return this; 103 | } 104 | 105 | /** 106 | * @param workspaceDir The path to non-default workspaces. 107 | * 108 | * @return builder 109 | * 110 | */ 111 | public Builder workspaceDir(String workspaceDir) { 112 | return workspaceDir(Output.of(workspaceDir)); 113 | } 114 | 115 | public GetLocalReferenceArgs build() { 116 | return $; 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/inputs/GetLocalReferencePlainArgs.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.inputs; 5 | 6 | import com.pulumi.core.annotations.Import; 7 | import java.lang.String; 8 | import java.util.Objects; 9 | import java.util.Optional; 10 | import javax.annotation.Nullable; 11 | 12 | 13 | public final class GetLocalReferencePlainArgs extends com.pulumi.resources.InvokeArgs { 14 | 15 | public static final GetLocalReferencePlainArgs Empty = new GetLocalReferencePlainArgs(); 16 | 17 | /** 18 | * The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 19 | * 20 | */ 21 | @Import(name="path") 22 | private @Nullable String path; 23 | 24 | /** 25 | * @return The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 26 | * 27 | */ 28 | public Optional path() { 29 | return Optional.ofNullable(this.path); 30 | } 31 | 32 | /** 33 | * The path to non-default workspaces. 34 | * 35 | */ 36 | @Import(name="workspaceDir") 37 | private @Nullable String workspaceDir; 38 | 39 | /** 40 | * @return The path to non-default workspaces. 41 | * 42 | */ 43 | public Optional workspaceDir() { 44 | return Optional.ofNullable(this.workspaceDir); 45 | } 46 | 47 | private GetLocalReferencePlainArgs() {} 48 | 49 | private GetLocalReferencePlainArgs(GetLocalReferencePlainArgs $) { 50 | this.path = $.path; 51 | this.workspaceDir = $.workspaceDir; 52 | } 53 | 54 | public static Builder builder() { 55 | return new Builder(); 56 | } 57 | public static Builder builder(GetLocalReferencePlainArgs defaults) { 58 | return new Builder(defaults); 59 | } 60 | 61 | public static final class Builder { 62 | private GetLocalReferencePlainArgs $; 63 | 64 | public Builder() { 65 | $ = new GetLocalReferencePlainArgs(); 66 | } 67 | 68 | public Builder(GetLocalReferencePlainArgs defaults) { 69 | $ = new GetLocalReferencePlainArgs(Objects.requireNonNull(defaults)); 70 | } 71 | 72 | /** 73 | * @param path The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 74 | * 75 | * @return builder 76 | * 77 | */ 78 | public Builder path(@Nullable String path) { 79 | $.path = path; 80 | return this; 81 | } 82 | 83 | /** 84 | * @param workspaceDir The path to non-default workspaces. 85 | * 86 | * @return builder 87 | * 88 | */ 89 | public Builder workspaceDir(@Nullable String workspaceDir) { 90 | $.workspaceDir = workspaceDir; 91 | return this; 92 | } 93 | 94 | public GetLocalReferencePlainArgs build() { 95 | return $; 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/inputs/GetRemoteReferenceArgs.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.inputs; 5 | 6 | import com.pulumi.core.Output; 7 | import com.pulumi.core.annotations.Import; 8 | import com.pulumi.core.internal.Codegen; 9 | import com.pulumi.exceptions.MissingRequiredPropertyException; 10 | import com.pulumi.terraform.state.inputs.WorkspacesArgs; 11 | import java.lang.String; 12 | import java.util.Objects; 13 | import java.util.Optional; 14 | import javax.annotation.Nullable; 15 | 16 | 17 | public final class GetRemoteReferenceArgs extends com.pulumi.resources.InvokeArgs { 18 | 19 | public static final GetRemoteReferenceArgs Empty = new GetRemoteReferenceArgs(); 20 | 21 | /** 22 | * The remote backend hostname to connect to. 23 | * 24 | */ 25 | @Import(name="hostname") 26 | private @Nullable Output hostname; 27 | 28 | /** 29 | * @return The remote backend hostname to connect to. 30 | * 31 | */ 32 | public Optional> hostname() { 33 | return Optional.ofNullable(this.hostname); 34 | } 35 | 36 | /** 37 | * The name of the organization containing the targeted workspace(s). 38 | * 39 | */ 40 | @Import(name="organization", required=true) 41 | private Output organization; 42 | 43 | /** 44 | * @return The name of the organization containing the targeted workspace(s). 45 | * 46 | */ 47 | public Output organization() { 48 | return this.organization; 49 | } 50 | 51 | /** 52 | * The token used to authenticate with the remote backend. 53 | * 54 | */ 55 | @Import(name="token") 56 | private @Nullable Output token; 57 | 58 | /** 59 | * @return The token used to authenticate with the remote backend. 60 | * 61 | */ 62 | public Optional> token() { 63 | return Optional.ofNullable(this.token); 64 | } 65 | 66 | @Import(name="workspaces", required=true) 67 | private Output workspaces; 68 | 69 | public Output workspaces() { 70 | return this.workspaces; 71 | } 72 | 73 | private GetRemoteReferenceArgs() {} 74 | 75 | private GetRemoteReferenceArgs(GetRemoteReferenceArgs $) { 76 | this.hostname = $.hostname; 77 | this.organization = $.organization; 78 | this.token = $.token; 79 | this.workspaces = $.workspaces; 80 | } 81 | 82 | public static Builder builder() { 83 | return new Builder(); 84 | } 85 | public static Builder builder(GetRemoteReferenceArgs defaults) { 86 | return new Builder(defaults); 87 | } 88 | 89 | public static final class Builder { 90 | private GetRemoteReferenceArgs $; 91 | 92 | public Builder() { 93 | $ = new GetRemoteReferenceArgs(); 94 | } 95 | 96 | public Builder(GetRemoteReferenceArgs defaults) { 97 | $ = new GetRemoteReferenceArgs(Objects.requireNonNull(defaults)); 98 | } 99 | 100 | /** 101 | * @param hostname The remote backend hostname to connect to. 102 | * 103 | * @return builder 104 | * 105 | */ 106 | public Builder hostname(@Nullable Output hostname) { 107 | $.hostname = hostname; 108 | return this; 109 | } 110 | 111 | /** 112 | * @param hostname The remote backend hostname to connect to. 113 | * 114 | * @return builder 115 | * 116 | */ 117 | public Builder hostname(String hostname) { 118 | return hostname(Output.of(hostname)); 119 | } 120 | 121 | /** 122 | * @param organization The name of the organization containing the targeted workspace(s). 123 | * 124 | * @return builder 125 | * 126 | */ 127 | public Builder organization(Output organization) { 128 | $.organization = organization; 129 | return this; 130 | } 131 | 132 | /** 133 | * @param organization The name of the organization containing the targeted workspace(s). 134 | * 135 | * @return builder 136 | * 137 | */ 138 | public Builder organization(String organization) { 139 | return organization(Output.of(organization)); 140 | } 141 | 142 | /** 143 | * @param token The token used to authenticate with the remote backend. 144 | * 145 | * @return builder 146 | * 147 | */ 148 | public Builder token(@Nullable Output token) { 149 | $.token = token; 150 | return this; 151 | } 152 | 153 | /** 154 | * @param token The token used to authenticate with the remote backend. 155 | * 156 | * @return builder 157 | * 158 | */ 159 | public Builder token(String token) { 160 | return token(Output.of(token)); 161 | } 162 | 163 | public Builder workspaces(Output workspaces) { 164 | $.workspaces = workspaces; 165 | return this; 166 | } 167 | 168 | public Builder workspaces(WorkspacesArgs workspaces) { 169 | return workspaces(Output.of(workspaces)); 170 | } 171 | 172 | public GetRemoteReferenceArgs build() { 173 | $.hostname = Codegen.stringProp("hostname").output().arg($.hostname).def("app.terraform.io").getNullable(); 174 | if ($.organization == null) { 175 | throw new MissingRequiredPropertyException("GetRemoteReferenceArgs", "organization"); 176 | } 177 | if ($.workspaces == null) { 178 | throw new MissingRequiredPropertyException("GetRemoteReferenceArgs", "workspaces"); 179 | } 180 | return $; 181 | } 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/inputs/GetRemoteReferencePlainArgs.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.inputs; 5 | 6 | import com.pulumi.core.annotations.Import; 7 | import com.pulumi.core.internal.Codegen; 8 | import com.pulumi.exceptions.MissingRequiredPropertyException; 9 | import com.pulumi.terraform.state.inputs.Workspaces; 10 | import java.lang.String; 11 | import java.util.Objects; 12 | import java.util.Optional; 13 | import javax.annotation.Nullable; 14 | 15 | 16 | public final class GetRemoteReferencePlainArgs extends com.pulumi.resources.InvokeArgs { 17 | 18 | public static final GetRemoteReferencePlainArgs Empty = new GetRemoteReferencePlainArgs(); 19 | 20 | /** 21 | * The remote backend hostname to connect to. 22 | * 23 | */ 24 | @Import(name="hostname") 25 | private @Nullable String hostname; 26 | 27 | /** 28 | * @return The remote backend hostname to connect to. 29 | * 30 | */ 31 | public Optional hostname() { 32 | return Optional.ofNullable(this.hostname); 33 | } 34 | 35 | /** 36 | * The name of the organization containing the targeted workspace(s). 37 | * 38 | */ 39 | @Import(name="organization", required=true) 40 | private String organization; 41 | 42 | /** 43 | * @return The name of the organization containing the targeted workspace(s). 44 | * 45 | */ 46 | public String organization() { 47 | return this.organization; 48 | } 49 | 50 | /** 51 | * The token used to authenticate with the remote backend. 52 | * 53 | */ 54 | @Import(name="token") 55 | private @Nullable String token; 56 | 57 | /** 58 | * @return The token used to authenticate with the remote backend. 59 | * 60 | */ 61 | public Optional token() { 62 | return Optional.ofNullable(this.token); 63 | } 64 | 65 | @Import(name="workspaces", required=true) 66 | private Workspaces workspaces; 67 | 68 | public Workspaces workspaces() { 69 | return this.workspaces; 70 | } 71 | 72 | private GetRemoteReferencePlainArgs() {} 73 | 74 | private GetRemoteReferencePlainArgs(GetRemoteReferencePlainArgs $) { 75 | this.hostname = $.hostname; 76 | this.organization = $.organization; 77 | this.token = $.token; 78 | this.workspaces = $.workspaces; 79 | } 80 | 81 | public static Builder builder() { 82 | return new Builder(); 83 | } 84 | public static Builder builder(GetRemoteReferencePlainArgs defaults) { 85 | return new Builder(defaults); 86 | } 87 | 88 | public static final class Builder { 89 | private GetRemoteReferencePlainArgs $; 90 | 91 | public Builder() { 92 | $ = new GetRemoteReferencePlainArgs(); 93 | } 94 | 95 | public Builder(GetRemoteReferencePlainArgs defaults) { 96 | $ = new GetRemoteReferencePlainArgs(Objects.requireNonNull(defaults)); 97 | } 98 | 99 | /** 100 | * @param hostname The remote backend hostname to connect to. 101 | * 102 | * @return builder 103 | * 104 | */ 105 | public Builder hostname(@Nullable String hostname) { 106 | $.hostname = hostname; 107 | return this; 108 | } 109 | 110 | /** 111 | * @param organization The name of the organization containing the targeted workspace(s). 112 | * 113 | * @return builder 114 | * 115 | */ 116 | public Builder organization(String organization) { 117 | $.organization = organization; 118 | return this; 119 | } 120 | 121 | /** 122 | * @param token The token used to authenticate with the remote backend. 123 | * 124 | * @return builder 125 | * 126 | */ 127 | public Builder token(@Nullable String token) { 128 | $.token = token; 129 | return this; 130 | } 131 | 132 | public Builder workspaces(Workspaces workspaces) { 133 | $.workspaces = workspaces; 134 | return this; 135 | } 136 | 137 | public GetRemoteReferencePlainArgs build() { 138 | $.hostname = Codegen.stringProp("hostname").arg($.hostname).def("app.terraform.io").getNullable(); 139 | if ($.organization == null) { 140 | throw new MissingRequiredPropertyException("GetRemoteReferencePlainArgs", "organization"); 141 | } 142 | if ($.workspaces == null) { 143 | throw new MissingRequiredPropertyException("GetRemoteReferencePlainArgs", "workspaces"); 144 | } 145 | return $; 146 | } 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/inputs/Workspaces.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.inputs; 5 | 6 | import com.pulumi.core.annotations.Import; 7 | import java.lang.String; 8 | import java.util.Objects; 9 | import java.util.Optional; 10 | import javax.annotation.Nullable; 11 | 12 | 13 | public final class Workspaces extends com.pulumi.resources.InvokeArgs { 14 | 15 | public static final Workspaces Empty = new Workspaces(); 16 | 17 | /** 18 | * The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 19 | * 20 | */ 21 | @Import(name="name") 22 | private @Nullable String name; 23 | 24 | /** 25 | * @return The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 26 | * 27 | */ 28 | public Optional name() { 29 | return Optional.ofNullable(this.name); 30 | } 31 | 32 | /** 33 | * A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 34 | * 35 | */ 36 | @Import(name="prefix") 37 | private @Nullable String prefix; 38 | 39 | /** 40 | * @return A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 41 | * 42 | */ 43 | public Optional prefix() { 44 | return Optional.ofNullable(this.prefix); 45 | } 46 | 47 | private Workspaces() {} 48 | 49 | private Workspaces(Workspaces $) { 50 | this.name = $.name; 51 | this.prefix = $.prefix; 52 | } 53 | 54 | public static Builder builder() { 55 | return new Builder(); 56 | } 57 | public static Builder builder(Workspaces defaults) { 58 | return new Builder(defaults); 59 | } 60 | 61 | public static final class Builder { 62 | private Workspaces $; 63 | 64 | public Builder() { 65 | $ = new Workspaces(); 66 | } 67 | 68 | public Builder(Workspaces defaults) { 69 | $ = new Workspaces(Objects.requireNonNull(defaults)); 70 | } 71 | 72 | /** 73 | * @param name The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 74 | * 75 | * @return builder 76 | * 77 | */ 78 | public Builder name(@Nullable String name) { 79 | $.name = name; 80 | return this; 81 | } 82 | 83 | /** 84 | * @param prefix A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 85 | * 86 | * @return builder 87 | * 88 | */ 89 | public Builder prefix(@Nullable String prefix) { 90 | $.prefix = prefix; 91 | return this; 92 | } 93 | 94 | public Workspaces build() { 95 | return $; 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/inputs/WorkspacesArgs.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.inputs; 5 | 6 | import com.pulumi.core.Output; 7 | import com.pulumi.core.annotations.Import; 8 | import java.lang.String; 9 | import java.util.Objects; 10 | import java.util.Optional; 11 | import javax.annotation.Nullable; 12 | 13 | 14 | public final class WorkspacesArgs extends com.pulumi.resources.ResourceArgs { 15 | 16 | public static final WorkspacesArgs Empty = new WorkspacesArgs(); 17 | 18 | /** 19 | * The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 20 | * 21 | */ 22 | @Import(name="name") 23 | private @Nullable Output name; 24 | 25 | /** 26 | * @return The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 27 | * 28 | */ 29 | public Optional> name() { 30 | return Optional.ofNullable(this.name); 31 | } 32 | 33 | /** 34 | * A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 35 | * 36 | */ 37 | @Import(name="prefix") 38 | private @Nullable Output prefix; 39 | 40 | /** 41 | * @return A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 42 | * 43 | */ 44 | public Optional> prefix() { 45 | return Optional.ofNullable(this.prefix); 46 | } 47 | 48 | private WorkspacesArgs() {} 49 | 50 | private WorkspacesArgs(WorkspacesArgs $) { 51 | this.name = $.name; 52 | this.prefix = $.prefix; 53 | } 54 | 55 | public static Builder builder() { 56 | return new Builder(); 57 | } 58 | public static Builder builder(WorkspacesArgs defaults) { 59 | return new Builder(defaults); 60 | } 61 | 62 | public static final class Builder { 63 | private WorkspacesArgs $; 64 | 65 | public Builder() { 66 | $ = new WorkspacesArgs(); 67 | } 68 | 69 | public Builder(WorkspacesArgs defaults) { 70 | $ = new WorkspacesArgs(Objects.requireNonNull(defaults)); 71 | } 72 | 73 | /** 74 | * @param name The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 75 | * 76 | * @return builder 77 | * 78 | */ 79 | public Builder name(@Nullable Output name) { 80 | $.name = name; 81 | return this; 82 | } 83 | 84 | /** 85 | * @param name The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 86 | * 87 | * @return builder 88 | * 89 | */ 90 | public Builder name(String name) { 91 | return name(Output.of(name)); 92 | } 93 | 94 | /** 95 | * @param prefix A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 96 | * 97 | * @return builder 98 | * 99 | */ 100 | public Builder prefix(@Nullable Output prefix) { 101 | $.prefix = prefix; 102 | return this; 103 | } 104 | 105 | /** 106 | * @param prefix A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 107 | * 108 | * @return builder 109 | * 110 | */ 111 | public Builder prefix(String prefix) { 112 | return prefix(Output.of(prefix)); 113 | } 114 | 115 | public WorkspacesArgs build() { 116 | return $; 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/outputs/GetLocalReferenceResult.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.outputs; 5 | 6 | import com.pulumi.core.annotations.CustomType; 7 | import com.pulumi.exceptions.MissingRequiredPropertyException; 8 | import java.lang.Object; 9 | import java.lang.String; 10 | import java.util.Map; 11 | import java.util.Objects; 12 | 13 | @CustomType 14 | public final class GetLocalReferenceResult { 15 | /** 16 | * @return The outputs displayed from Terraform state. 17 | * 18 | */ 19 | private Map outputs; 20 | 21 | private GetLocalReferenceResult() {} 22 | /** 23 | * @return The outputs displayed from Terraform state. 24 | * 25 | */ 26 | public Map outputs() { 27 | return this.outputs; 28 | } 29 | 30 | public static Builder builder() { 31 | return new Builder(); 32 | } 33 | 34 | public static Builder builder(GetLocalReferenceResult defaults) { 35 | return new Builder(defaults); 36 | } 37 | @CustomType.Builder 38 | public static final class Builder { 39 | private Map outputs; 40 | public Builder() {} 41 | public Builder(GetLocalReferenceResult defaults) { 42 | Objects.requireNonNull(defaults); 43 | this.outputs = defaults.outputs; 44 | } 45 | 46 | @CustomType.Setter 47 | public Builder outputs(Map outputs) { 48 | if (outputs == null) { 49 | throw new MissingRequiredPropertyException("GetLocalReferenceResult", "outputs"); 50 | } 51 | this.outputs = outputs; 52 | return this; 53 | } 54 | public GetLocalReferenceResult build() { 55 | final var _resultValue = new GetLocalReferenceResult(); 56 | _resultValue.outputs = outputs; 57 | return _resultValue; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sdk/java/src/main/java/com/pulumi/terraform/state/outputs/GetRemoteReferenceResult.java: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-java. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | package com.pulumi.terraform.state.outputs; 5 | 6 | import com.pulumi.core.annotations.CustomType; 7 | import com.pulumi.exceptions.MissingRequiredPropertyException; 8 | import java.lang.Object; 9 | import java.lang.String; 10 | import java.util.Map; 11 | import java.util.Objects; 12 | 13 | @CustomType 14 | public final class GetRemoteReferenceResult { 15 | /** 16 | * @return The outputs displayed from Terraform state. 17 | * 18 | */ 19 | private Map outputs; 20 | 21 | private GetRemoteReferenceResult() {} 22 | /** 23 | * @return The outputs displayed from Terraform state. 24 | * 25 | */ 26 | public Map outputs() { 27 | return this.outputs; 28 | } 29 | 30 | public static Builder builder() { 31 | return new Builder(); 32 | } 33 | 34 | public static Builder builder(GetRemoteReferenceResult defaults) { 35 | return new Builder(defaults); 36 | } 37 | @CustomType.Builder 38 | public static final class Builder { 39 | private Map outputs; 40 | public Builder() {} 41 | public Builder(GetRemoteReferenceResult defaults) { 42 | Objects.requireNonNull(defaults); 43 | this.outputs = defaults.outputs; 44 | } 45 | 46 | @CustomType.Setter 47 | public Builder outputs(Map outputs) { 48 | if (outputs == null) { 49 | throw new MissingRequiredPropertyException("GetRemoteReferenceResult", "outputs"); 50 | } 51 | this.outputs = outputs; 52 | return this; 53 | } 54 | public GetRemoteReferenceResult build() { 55 | final var _resultValue = new GetRemoteReferenceResult(); 56 | _resultValue.outputs = outputs; 57 | return _resultValue; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sdk/nodejs/README.md: -------------------------------------------------------------------------------- 1 | The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 2 | -------------------------------------------------------------------------------- /sdk/nodejs/index.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as pulumi from "@pulumi/pulumi"; 5 | import * as utilities from "./utilities"; 6 | 7 | // Export members: 8 | export { ProviderArgs } from "./provider"; 9 | export type Provider = import("./provider").Provider; 10 | export const Provider: typeof import("./provider").Provider = null as any; 11 | utilities.lazyLoad(exports, ["Provider"], () => require("./provider")); 12 | 13 | 14 | // Export sub-modules: 15 | import * as state from "./state"; 16 | import * as types from "./types"; 17 | 18 | export { 19 | state, 20 | types, 21 | }; 22 | pulumi.runtime.registerResourcePackage("terraform", { 23 | version: utilities.getVersion(), 24 | constructProvider: (name: string, type: string, urn: string): pulumi.ProviderResource => { 25 | if (type !== "pulumi:providers:terraform") { 26 | throw new Error(`unknown provider type ${type}`); 27 | } 28 | return new Provider(name, undefined, { urn }); 29 | }, 30 | }); 31 | -------------------------------------------------------------------------------- /sdk/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pulumi/terraform", 3 | "version": "6.0.0-alpha.0+dev", 4 | "keywords": [ 5 | "terraform", 6 | "kind/native", 7 | "category/utility" 8 | ], 9 | "homepage": "https://pulumi.com", 10 | "repository": "https://github.com/pulumi/pulumi-terraform", 11 | "license": "Apache-2.0", 12 | "scripts": { 13 | "build": "tsc" 14 | }, 15 | "dependencies": { 16 | "@pulumi/pulumi": "^3.142.0" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "^18", 20 | "typescript": "^4.3.5" 21 | }, 22 | "pulumi": { 23 | "resource": true, 24 | "name": "terraform", 25 | "version": "6.0.0-alpha.0+dev" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sdk/nodejs/provider.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as pulumi from "@pulumi/pulumi"; 5 | import * as utilities from "./utilities"; 6 | 7 | export class Provider extends pulumi.ProviderResource { 8 | /** @internal */ 9 | public static readonly __pulumiType = 'terraform'; 10 | 11 | /** 12 | * Returns true if the given object is an instance of Provider. This is designed to work even 13 | * when multiple copies of the Pulumi SDK have been loaded into the same process. 14 | */ 15 | public static isInstance(obj: any): obj is Provider { 16 | if (obj === undefined || obj === null) { 17 | return false; 18 | } 19 | return obj['__pulumiType'] === "pulumi:providers:" + Provider.__pulumiType; 20 | } 21 | 22 | 23 | /** 24 | * Create a Provider resource with the given unique name, arguments, and options. 25 | * 26 | * @param name The _unique_ name of the resource. 27 | * @param args The arguments to use to populate this resource's properties. 28 | * @param opts A bag of options that control this resource's behavior. 29 | */ 30 | constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { 31 | let resourceInputs: pulumi.Inputs = {}; 32 | opts = opts || {}; 33 | { 34 | } 35 | opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); 36 | super(Provider.__pulumiType, name, resourceInputs, opts); 37 | } 38 | } 39 | 40 | /** 41 | * The set of arguments for constructing a Provider resource. 42 | */ 43 | export interface ProviderArgs { 44 | } 45 | -------------------------------------------------------------------------------- /sdk/nodejs/state/getLocalReference.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as pulumi from "@pulumi/pulumi"; 5 | import * as utilities from "../utilities"; 6 | 7 | /** 8 | * Access state from the local filesystem. 9 | */ 10 | export function getLocalReference(args?: GetLocalReferenceArgs, opts?: pulumi.InvokeOptions): Promise { 11 | args = args || {}; 12 | opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); 13 | return pulumi.runtime.invoke("terraform:state:getLocalReference", { 14 | "path": args.path, 15 | "workspaceDir": args.workspaceDir, 16 | }, opts); 17 | } 18 | 19 | export interface GetLocalReferenceArgs { 20 | /** 21 | * The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 22 | */ 23 | path?: string; 24 | /** 25 | * The path to non-default workspaces. 26 | */ 27 | workspaceDir?: string; 28 | } 29 | 30 | /** 31 | * The result of fetching from a Terraform state store. 32 | */ 33 | export interface GetLocalReferenceResult { 34 | /** 35 | * The outputs displayed from Terraform state. 36 | */ 37 | readonly outputs: {[key: string]: any}; 38 | } 39 | /** 40 | * Access state from the local filesystem. 41 | */ 42 | export function getLocalReferenceOutput(args?: GetLocalReferenceOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output { 43 | args = args || {}; 44 | opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); 45 | return pulumi.runtime.invokeOutput("terraform:state:getLocalReference", { 46 | "path": args.path, 47 | "workspaceDir": args.workspaceDir, 48 | }, opts); 49 | } 50 | 51 | export interface GetLocalReferenceOutputArgs { 52 | /** 53 | * The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 54 | */ 55 | path?: pulumi.Input; 56 | /** 57 | * The path to non-default workspaces. 58 | */ 59 | workspaceDir?: pulumi.Input; 60 | } 61 | -------------------------------------------------------------------------------- /sdk/nodejs/state/getRemoteReference.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as pulumi from "@pulumi/pulumi"; 5 | import * as inputs from "../types/input"; 6 | import * as outputs from "../types/output"; 7 | import * as utilities from "../utilities"; 8 | 9 | /** 10 | * Access state from a remote backend. 11 | */ 12 | export function getRemoteReference(args: GetRemoteReferenceArgs, opts?: pulumi.InvokeOptions): Promise { 13 | opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); 14 | return pulumi.runtime.invoke("terraform:state:getRemoteReference", { 15 | "hostname": args.hostname, 16 | "organization": args.organization, 17 | "token": args.token, 18 | "workspaces": args.workspaces, 19 | }, opts); 20 | } 21 | 22 | export interface GetRemoteReferenceArgs { 23 | /** 24 | * The remote backend hostname to connect to. 25 | */ 26 | hostname?: string; 27 | /** 28 | * The name of the organization containing the targeted workspace(s). 29 | */ 30 | organization: string; 31 | /** 32 | * The token used to authenticate with the remote backend. 33 | */ 34 | token?: string; 35 | workspaces: inputs.state.Workspaces; 36 | } 37 | 38 | /** 39 | * The result of fetching from a Terraform state store. 40 | */ 41 | export interface GetRemoteReferenceResult { 42 | /** 43 | * The outputs displayed from Terraform state. 44 | */ 45 | readonly outputs: {[key: string]: any}; 46 | } 47 | /** 48 | * Access state from a remote backend. 49 | */ 50 | export function getRemoteReferenceOutput(args: GetRemoteReferenceOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output { 51 | opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); 52 | return pulumi.runtime.invokeOutput("terraform:state:getRemoteReference", { 53 | "hostname": args.hostname, 54 | "organization": args.organization, 55 | "token": args.token, 56 | "workspaces": args.workspaces, 57 | }, opts); 58 | } 59 | 60 | export interface GetRemoteReferenceOutputArgs { 61 | /** 62 | * The remote backend hostname to connect to. 63 | */ 64 | hostname?: pulumi.Input; 65 | /** 66 | * The name of the organization containing the targeted workspace(s). 67 | */ 68 | organization: pulumi.Input; 69 | /** 70 | * The token used to authenticate with the remote backend. 71 | */ 72 | token?: pulumi.Input; 73 | workspaces: pulumi.Input; 74 | } 75 | -------------------------------------------------------------------------------- /sdk/nodejs/state/index.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as utilities from "../utilities"; 5 | 6 | // Export members: 7 | export { GetLocalReferenceArgs, GetLocalReferenceResult, GetLocalReferenceOutputArgs } from "./getLocalReference"; 8 | export const getLocalReference: typeof import("./getLocalReference").getLocalReference = null as any; 9 | export const getLocalReferenceOutput: typeof import("./getLocalReference").getLocalReferenceOutput = null as any; 10 | utilities.lazyLoad(exports, ["getLocalReference","getLocalReferenceOutput"], () => require("./getLocalReference")); 11 | 12 | export { GetRemoteReferenceArgs, GetRemoteReferenceResult, GetRemoteReferenceOutputArgs } from "./getRemoteReference"; 13 | export const getRemoteReference: typeof import("./getRemoteReference").getRemoteReference = null as any; 14 | export const getRemoteReferenceOutput: typeof import("./getRemoteReference").getRemoteReferenceOutput = null as any; 15 | utilities.lazyLoad(exports, ["getRemoteReference","getRemoteReferenceOutput"], () => require("./getRemoteReference")); 16 | 17 | -------------------------------------------------------------------------------- /sdk/nodejs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "bin", 4 | "target": "es2016", 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "declaration": true, 8 | "sourceMap": true, 9 | "stripInternal": true, 10 | "experimentalDecorators": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "strict": true 14 | }, 15 | "files": [ 16 | "index.ts", 17 | "provider.ts", 18 | "state/getLocalReference.ts", 19 | "state/getRemoteReference.ts", 20 | "state/index.ts", 21 | "types/index.ts", 22 | "types/input.ts", 23 | "types/output.ts", 24 | "utilities.ts" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /sdk/nodejs/types/index.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as utilities from "../utilities"; 5 | 6 | // Export sub-modules: 7 | import * as input from "./input"; 8 | import * as output from "./output"; 9 | 10 | export { 11 | input, 12 | output, 13 | }; 14 | -------------------------------------------------------------------------------- /sdk/nodejs/types/input.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as pulumi from "@pulumi/pulumi"; 5 | import * as inputs from "../types/input"; 6 | import * as outputs from "../types/output"; 7 | 8 | export namespace state { 9 | export interface Workspaces { 10 | /** 11 | * The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 12 | */ 13 | name?: string; 14 | /** 15 | * A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 16 | */ 17 | prefix?: string; 18 | } 19 | 20 | export interface WorkspacesArgs { 21 | /** 22 | * The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 23 | */ 24 | name?: pulumi.Input; 25 | /** 26 | * A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 27 | */ 28 | prefix?: pulumi.Input; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sdk/nodejs/types/output.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | import * as pulumi from "@pulumi/pulumi"; 5 | import * as inputs from "../types/input"; 6 | import * as outputs from "../types/output"; 7 | 8 | export namespace state { 9 | } 10 | -------------------------------------------------------------------------------- /sdk/nodejs/utilities.ts: -------------------------------------------------------------------------------- 1 | // *** WARNING: this file was generated by pulumi-language-nodejs. *** 2 | // *** Do not edit by hand unless you're certain you know what you are doing! *** 3 | 4 | 5 | import * as runtime from "@pulumi/pulumi/runtime"; 6 | import * as pulumi from "@pulumi/pulumi"; 7 | 8 | export function getEnv(...vars: string[]): string | undefined { 9 | for (const v of vars) { 10 | const value = process.env[v]; 11 | if (value) { 12 | return value; 13 | } 14 | } 15 | return undefined; 16 | } 17 | 18 | export function getEnvBoolean(...vars: string[]): boolean | undefined { 19 | const s = getEnv(...vars); 20 | if (s !== undefined) { 21 | // NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what 22 | // Terraform uses internally when parsing boolean values. 23 | if (["1", "t", "T", "true", "TRUE", "True"].find(v => v === s) !== undefined) { 24 | return true; 25 | } 26 | if (["0", "f", "F", "false", "FALSE", "False"].find(v => v === s) !== undefined) { 27 | return false; 28 | } 29 | } 30 | return undefined; 31 | } 32 | 33 | export function getEnvNumber(...vars: string[]): number | undefined { 34 | const s = getEnv(...vars); 35 | if (s !== undefined) { 36 | const f = parseFloat(s); 37 | if (!isNaN(f)) { 38 | return f; 39 | } 40 | } 41 | return undefined; 42 | } 43 | 44 | export function getVersion(): string { 45 | let version = require('./package.json').version; 46 | // Node allows for the version to be prefixed by a "v", while semver doesn't. 47 | // If there is a v, strip it off. 48 | if (version.indexOf('v') === 0) { 49 | version = version.slice(1); 50 | } 51 | return version; 52 | } 53 | 54 | /** @internal */ 55 | export function resourceOptsDefaults(): any { 56 | return { version: getVersion() }; 57 | } 58 | 59 | /** @internal */ 60 | export function lazyLoad(exports: any, props: string[], loadModule: any) { 61 | for (let property of props) { 62 | Object.defineProperty(exports, property, { 63 | enumerable: true, 64 | get: function() { 65 | return loadModule()[property]; 66 | }, 67 | }); 68 | } 69 | } 70 | 71 | export async function callAsync( 72 | tok: string, 73 | props: pulumi.Inputs, 74 | res?: pulumi.Resource, 75 | opts?: {property?: string}, 76 | ): Promise { 77 | const o: any = runtime.call(tok, props, res); 78 | const value = await o.promise(true /*withUnknowns*/); 79 | const isKnown = await o.isKnown; 80 | const isSecret = await o.isSecret; 81 | const problem: string|undefined = 82 | !isKnown ? "an unknown value" 83 | : isSecret ? "a secret value" 84 | : undefined; 85 | // Ingoring o.resources silently. They are typically non-empty, r.f() calls include r as a dependency. 86 | if (problem) { 87 | throw new Error(`Plain resource method "${tok}" incorrectly returned ${problem}. ` + 88 | "This is an error in the provider, please report this to the provider developer."); 89 | } 90 | // Extract a single property if requested. 91 | if (opts && opts.property) { 92 | return value[opts.property]; 93 | } 94 | return value; 95 | } 96 | -------------------------------------------------------------------------------- /sdk/python/README.md: -------------------------------------------------------------------------------- 1 | # Pulumi Terraform Provider 2 | 3 | The Terraform resource provider for Pulumi lets you consume the outputs contained in 4 | Terraform state files from your Pulumi programs. 5 | 6 | > [!IMPORTANT] 7 | > For reference docs and installation instructions, please go to 8 | > . 9 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/README.md: -------------------------------------------------------------------------------- 1 | The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs. 2 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # *** WARNING: this file was generated by pulumi-language-python. *** 3 | # *** Do not edit by hand unless you're certain you know what you are doing! *** 4 | 5 | import builtins 6 | from . import _utilities 7 | import typing 8 | # Export this package's modules as members: 9 | from .provider import * 10 | 11 | # Make subpackages available: 12 | if typing.TYPE_CHECKING: 13 | import pulumi_terraform.state as __state 14 | state = __state 15 | else: 16 | state = _utilities.lazy_import('pulumi_terraform.state') 17 | 18 | _utilities.register( 19 | resource_modules=""" 20 | [] 21 | """, 22 | resource_packages=""" 23 | [ 24 | { 25 | "pkg": "terraform", 26 | "token": "pulumi:providers:terraform", 27 | "fqn": "pulumi_terraform", 28 | "class": "Provider" 29 | } 30 | ] 31 | """ 32 | ) 33 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/provider.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # *** WARNING: this file was generated by pulumi-language-python. *** 3 | # *** Do not edit by hand unless you're certain you know what you are doing! *** 4 | 5 | import builtins 6 | import copy 7 | import warnings 8 | import sys 9 | import pulumi 10 | import pulumi.runtime 11 | from typing import Any, Mapping, Optional, Sequence, Union, overload 12 | if sys.version_info >= (3, 11): 13 | from typing import NotRequired, TypedDict, TypeAlias 14 | else: 15 | from typing_extensions import NotRequired, TypedDict, TypeAlias 16 | from . import _utilities 17 | 18 | __all__ = ['ProviderArgs', 'Provider'] 19 | 20 | @pulumi.input_type 21 | class ProviderArgs: 22 | def __init__(__self__): 23 | """ 24 | The set of arguments for constructing a Provider resource. 25 | """ 26 | pass 27 | 28 | 29 | class Provider(pulumi.ProviderResource): 30 | @overload 31 | def __init__(__self__, 32 | resource_name: str, 33 | opts: Optional[pulumi.ResourceOptions] = None, 34 | __props__=None): 35 | """ 36 | Create a Terraform resource with the given unique name, props, and options. 37 | :param str resource_name: The name of the resource. 38 | :param pulumi.ResourceOptions opts: Options for the resource. 39 | """ 40 | ... 41 | @overload 42 | def __init__(__self__, 43 | resource_name: str, 44 | args: Optional[ProviderArgs] = None, 45 | opts: Optional[pulumi.ResourceOptions] = None): 46 | """ 47 | Create a Terraform resource with the given unique name, props, and options. 48 | :param str resource_name: The name of the resource. 49 | :param ProviderArgs args: The arguments to use to populate this resource's properties. 50 | :param pulumi.ResourceOptions opts: Options for the resource. 51 | """ 52 | ... 53 | def __init__(__self__, resource_name: str, *args, **kwargs): 54 | resource_args, opts = _utilities.get_resource_args_opts(ProviderArgs, pulumi.ResourceOptions, *args, **kwargs) 55 | if resource_args is not None: 56 | __self__._internal_init(resource_name, opts, **resource_args.__dict__) 57 | else: 58 | __self__._internal_init(resource_name, *args, **kwargs) 59 | 60 | def _internal_init(__self__, 61 | resource_name: str, 62 | opts: Optional[pulumi.ResourceOptions] = None, 63 | __props__=None): 64 | opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts) 65 | if not isinstance(opts, pulumi.ResourceOptions): 66 | raise TypeError('Expected resource options to be a ResourceOptions instance') 67 | if opts.id is None: 68 | if __props__ is not None: 69 | raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource') 70 | __props__ = ProviderArgs.__new__(ProviderArgs) 71 | 72 | super(Provider, __self__).__init__( 73 | 'terraform', 74 | resource_name, 75 | __props__, 76 | opts) 77 | 78 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/pulumi-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "resource": true, 3 | "name": "terraform", 4 | "version": "6.0.0-alpha.0+dev" 5 | } 6 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pulumi/pulumi-terraform/7aa5899413280c98b545daf2a84d402cbda6ece3/sdk/python/pulumi_terraform/py.typed -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/state/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # *** WARNING: this file was generated by pulumi-language-python. *** 3 | # *** Do not edit by hand unless you're certain you know what you are doing! *** 4 | 5 | import builtins 6 | from .. import _utilities 7 | import typing 8 | # Export this package's modules as members: 9 | from .get_local_reference import * 10 | from .get_remote_reference import * 11 | from ._inputs import * 12 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/state/_inputs.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # *** WARNING: this file was generated by pulumi-language-python. *** 3 | # *** Do not edit by hand unless you're certain you know what you are doing! *** 4 | 5 | import builtins 6 | import copy 7 | import warnings 8 | import sys 9 | import pulumi 10 | import pulumi.runtime 11 | from typing import Any, Mapping, Optional, Sequence, Union, overload 12 | if sys.version_info >= (3, 11): 13 | from typing import NotRequired, TypedDict, TypeAlias 14 | else: 15 | from typing_extensions import NotRequired, TypedDict, TypeAlias 16 | from .. import _utilities 17 | 18 | __all__ = [ 19 | 'Workspaces', 20 | 'WorkspacesDict', 21 | ] 22 | 23 | MYPY = False 24 | 25 | if not MYPY: 26 | class WorkspacesDict(TypedDict): 27 | name: NotRequired[builtins.str] 28 | """ 29 | The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 30 | """ 31 | prefix: NotRequired[builtins.str] 32 | """ 33 | A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 34 | """ 35 | elif False: 36 | WorkspacesDict: TypeAlias = Mapping[str, Any] 37 | 38 | @pulumi.input_type 39 | class Workspaces: 40 | def __init__(__self__, *, 41 | name: Optional[builtins.str] = None, 42 | prefix: Optional[builtins.str] = None): 43 | """ 44 | :param builtins.str name: The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 45 | :param builtins.str prefix: A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 46 | """ 47 | if name is not None: 48 | pulumi.set(__self__, "name", name) 49 | if prefix is not None: 50 | pulumi.set(__self__, "prefix", prefix) 51 | 52 | @property 53 | @pulumi.getter 54 | def name(self) -> Optional[builtins.str]: 55 | """ 56 | The full name of one remote workspace. When configured, only the default workspace can be used. This option conflicts with prefix. 57 | """ 58 | return pulumi.get(self, "name") 59 | 60 | @name.setter 61 | def name(self, value: Optional[builtins.str]): 62 | pulumi.set(self, "name", value) 63 | 64 | @property 65 | @pulumi.getter 66 | def prefix(self) -> Optional[builtins.str]: 67 | """ 68 | A prefix used in the names of one or more remote workspaces, all of which can be used with this configuration. The full workspace names are used in HCP Terraform, and the short names (minus the prefix) are used on the command line for Terraform CLI workspaces. If omitted, only the default workspace can be used. This option conflicts with name. 69 | """ 70 | return pulumi.get(self, "prefix") 71 | 72 | @prefix.setter 73 | def prefix(self, value: Optional[builtins.str]): 74 | pulumi.set(self, "prefix", value) 75 | 76 | 77 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/state/get_local_reference.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # *** WARNING: this file was generated by pulumi-language-python. *** 3 | # *** Do not edit by hand unless you're certain you know what you are doing! *** 4 | 5 | import builtins 6 | import copy 7 | import warnings 8 | import sys 9 | import pulumi 10 | import pulumi.runtime 11 | from typing import Any, Mapping, Optional, Sequence, Union, overload 12 | if sys.version_info >= (3, 11): 13 | from typing import NotRequired, TypedDict, TypeAlias 14 | else: 15 | from typing_extensions import NotRequired, TypedDict, TypeAlias 16 | from .. import _utilities 17 | 18 | __all__ = [ 19 | 'GetLocalReferenceResult', 20 | 'AwaitableGetLocalReferenceResult', 21 | 'get_local_reference', 22 | 'get_local_reference_output', 23 | ] 24 | 25 | @pulumi.output_type 26 | class GetLocalReferenceResult: 27 | """ 28 | The result of fetching from a Terraform state store. 29 | """ 30 | def __init__(__self__, outputs=None): 31 | if outputs and not isinstance(outputs, dict): 32 | raise TypeError("Expected argument 'outputs' to be a dict") 33 | pulumi.set(__self__, "outputs", outputs) 34 | 35 | @property 36 | @pulumi.getter 37 | def outputs(self) -> Mapping[str, Any]: 38 | """ 39 | The outputs displayed from Terraform state. 40 | """ 41 | return pulumi.get(self, "outputs") 42 | 43 | 44 | class AwaitableGetLocalReferenceResult(GetLocalReferenceResult): 45 | # pylint: disable=using-constant-test 46 | def __await__(self): 47 | if False: 48 | yield self 49 | return GetLocalReferenceResult( 50 | outputs=self.outputs) 51 | 52 | 53 | def get_local_reference(path: Optional[builtins.str] = None, 54 | workspace_dir: Optional[builtins.str] = None, 55 | opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetLocalReferenceResult: 56 | """ 57 | Access state from the local filesystem. 58 | 59 | 60 | :param builtins.str path: The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 61 | :param builtins.str workspace_dir: The path to non-default workspaces. 62 | """ 63 | __args__ = dict() 64 | __args__['path'] = path 65 | __args__['workspaceDir'] = workspace_dir 66 | opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts) 67 | __ret__ = pulumi.runtime.invoke('terraform:state:getLocalReference', __args__, opts=opts, typ=GetLocalReferenceResult).value 68 | 69 | return AwaitableGetLocalReferenceResult( 70 | outputs=pulumi.get(__ret__, 'outputs')) 71 | def get_local_reference_output(path: Optional[pulumi.Input[Optional[builtins.str]]] = None, 72 | workspace_dir: Optional[pulumi.Input[Optional[builtins.str]]] = None, 73 | opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetLocalReferenceResult]: 74 | """ 75 | Access state from the local filesystem. 76 | 77 | 78 | :param builtins.str path: The path to the tfstate file. This defaults to "terraform.tfstate" relative to the root module by default. 79 | :param builtins.str workspace_dir: The path to non-default workspaces. 80 | """ 81 | __args__ = dict() 82 | __args__['path'] = path 83 | __args__['workspaceDir'] = workspace_dir 84 | opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts) 85 | __ret__ = pulumi.runtime.invoke_output('terraform:state:getLocalReference', __args__, opts=opts, typ=GetLocalReferenceResult) 86 | return __ret__.apply(lambda __response__: GetLocalReferenceResult( 87 | outputs=pulumi.get(__response__, 'outputs'))) 88 | -------------------------------------------------------------------------------- /sdk/python/pulumi_terraform/state/get_remote_reference.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # *** WARNING: this file was generated by pulumi-language-python. *** 3 | # *** Do not edit by hand unless you're certain you know what you are doing! *** 4 | 5 | import builtins 6 | import copy 7 | import warnings 8 | import sys 9 | import pulumi 10 | import pulumi.runtime 11 | from typing import Any, Mapping, Optional, Sequence, Union, overload 12 | if sys.version_info >= (3, 11): 13 | from typing import NotRequired, TypedDict, TypeAlias 14 | else: 15 | from typing_extensions import NotRequired, TypedDict, TypeAlias 16 | from .. import _utilities 17 | from ._inputs import * 18 | 19 | __all__ = [ 20 | 'GetRemoteReferenceResult', 21 | 'AwaitableGetRemoteReferenceResult', 22 | 'get_remote_reference', 23 | 'get_remote_reference_output', 24 | ] 25 | 26 | @pulumi.output_type 27 | class GetRemoteReferenceResult: 28 | """ 29 | The result of fetching from a Terraform state store. 30 | """ 31 | def __init__(__self__, outputs=None): 32 | if outputs and not isinstance(outputs, dict): 33 | raise TypeError("Expected argument 'outputs' to be a dict") 34 | pulumi.set(__self__, "outputs", outputs) 35 | 36 | @property 37 | @pulumi.getter 38 | def outputs(self) -> Mapping[str, Any]: 39 | """ 40 | The outputs displayed from Terraform state. 41 | """ 42 | return pulumi.get(self, "outputs") 43 | 44 | 45 | class AwaitableGetRemoteReferenceResult(GetRemoteReferenceResult): 46 | # pylint: disable=using-constant-test 47 | def __await__(self): 48 | if False: 49 | yield self 50 | return GetRemoteReferenceResult( 51 | outputs=self.outputs) 52 | 53 | 54 | def get_remote_reference(hostname: Optional[builtins.str] = None, 55 | organization: Optional[builtins.str] = None, 56 | token: Optional[builtins.str] = None, 57 | workspaces: Optional[Union['Workspaces', 'WorkspacesDict']] = None, 58 | opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetRemoteReferenceResult: 59 | """ 60 | Access state from a remote backend. 61 | 62 | 63 | :param builtins.str hostname: The remote backend hostname to connect to. 64 | :param builtins.str organization: The name of the organization containing the targeted workspace(s). 65 | :param builtins.str token: The token used to authenticate with the remote backend. 66 | """ 67 | __args__ = dict() 68 | __args__['hostname'] = hostname 69 | __args__['organization'] = organization 70 | __args__['token'] = token 71 | __args__['workspaces'] = workspaces 72 | opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts) 73 | __ret__ = pulumi.runtime.invoke('terraform:state:getRemoteReference', __args__, opts=opts, typ=GetRemoteReferenceResult).value 74 | 75 | return AwaitableGetRemoteReferenceResult( 76 | outputs=pulumi.get(__ret__, 'outputs')) 77 | def get_remote_reference_output(hostname: Optional[pulumi.Input[Optional[builtins.str]]] = None, 78 | organization: Optional[pulumi.Input[builtins.str]] = None, 79 | token: Optional[pulumi.Input[Optional[builtins.str]]] = None, 80 | workspaces: Optional[pulumi.Input[Union['Workspaces', 'WorkspacesDict']]] = None, 81 | opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetRemoteReferenceResult]: 82 | """ 83 | Access state from a remote backend. 84 | 85 | 86 | :param builtins.str hostname: The remote backend hostname to connect to. 87 | :param builtins.str organization: The name of the organization containing the targeted workspace(s). 88 | :param builtins.str token: The token used to authenticate with the remote backend. 89 | """ 90 | __args__ = dict() 91 | __args__['hostname'] = hostname 92 | __args__['organization'] = organization 93 | __args__['token'] = token 94 | __args__['workspaces'] = workspaces 95 | opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts) 96 | __ret__ = pulumi.runtime.invoke_output('terraform:state:getRemoteReference', __args__, opts=opts, typ=GetRemoteReferenceResult) 97 | return __ret__.apply(lambda __response__: GetRemoteReferenceResult( 98 | outputs=pulumi.get(__response__, 'outputs'))) 99 | -------------------------------------------------------------------------------- /sdk/python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "pulumi_terraform" 3 | description = "The Terraform provider for Pulumi lets you consume the outputs contained in Terraform state from your Pulumi programs." 4 | dependencies = ["parver>=0.2.1", "pulumi>=3.142.0,<4.0.0", "semver>=2.8.1", "typing-extensions>=4.11; python_version < \"3.11\""] 5 | keywords = ["terraform", "kind/native", "category/utility"] 6 | readme = "README.md" 7 | requires-python = ">=3.9" 8 | version = "6.0.0a0+dev" 9 | [project.license] 10 | text = "Apache-2.0" 11 | [project.urls] 12 | Homepage = "https://pulumi.com" 13 | Repository = "https://github.com/pulumi/pulumi-terraform" 14 | 15 | [build-system] 16 | requires = ["setuptools>=61.0"] 17 | build-backend = "setuptools.build_meta" 18 | 19 | [tool] 20 | [tool.setuptools] 21 | [tool.setuptools.package-data] 22 | pulumi_terraform = ["py.typed", "pulumi-plugin.json"] 23 | --------------------------------------------------------------------------------