Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hashicorp/tf-sdk-migrator
CLI tool to migrate Terraform providers to the new plugin SDK
https://github.com/hashicorp/tf-sdk-migrator
go-sdk golang terraform terraform-provider
Last synced: 16 days ago
JSON representation
CLI tool to migrate Terraform providers to the new plugin SDK
- Host: GitHub
- URL: https://github.com/hashicorp/tf-sdk-migrator
- Owner: hashicorp
- License: mpl-2.0
- Archived: true
- Created: 2019-07-15T15:14:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T20:43:07.000Z (over 2 years ago)
- Last Synced: 2025-01-08T13:07:43.332Z (29 days ago)
- Topics: go-sdk, golang, terraform, terraform-provider
- Language: Go
- Homepage:
- Size: 1.01 MB
- Stars: 11
- Watchers: 12
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# tf-sdk-migrator
**ARCHIVED: This project has been archived since there are no more plans for feature work. Provider developers wishing to migrate their SDK from terraform to terraform-plugin-sdk or from terraform-plugin-sdk v1 to v2 can still automate part of those processes using this tool.**
The Terraform provider plugin SDK, previously part of the [github.com/hashicorp/terraform](https://github.com/hashicorp/terraform) "Core" Go module, has been moved to a new Go module, [github.com/hashicorp/terraform-plugin-sdk](https://github.com/hashicorp/terraform-plugin-sdk). Terraform providers should now import `hashicorp/terraform-plugin-sdk`.
`tf-sdk-migrator` is a CLI tool which will migrate a Terraform provider to the new SDK module by rewriting import paths. `tf-sdk-migrator check` checks the eligibility of the Provider for migration.
## Installation
```sh
go install github.com/hashicorp/tf-sdk-migrator
$GOBIN/tf-sdk-migrator
```## `tf-sdk-migrator check`: check eligibility for migration
Checks whether a Terraform provider is ready to migrate to the newly extracted Terraform SDK package.
```sh
tf-sdk-migrator check [--help] [--csv] PATH
```Outputs a report containing:
- Go version used in provider (soft requirement)
- Whether the provider uses Go modules
- Version of `hashicorp/terraform` used
- Whether the provider uses any `hashicorp/terraform` packages that are not in `hashicorp/terraform-plugin-sdk`
The `--csv` flag will output values in CSV format.Exits 0 if the provider meets all the hard requirements, 1 otherwise.
The Go version requirement is a "soft" requirement: it is strongly recommended to upgrade to Go version 1.12+ before migrating to the new SDK, but the migration can still be performed if this requirement is not met.
## `tf-sdk-migrator migrate`: migrate to standalone SDK
Migrates the Terraform provider to the new extracted SDK (`github.com/hashicorp/terraform-plugin-sdk`), replacing references to the old SDK (`github.com/hashicorp/terraform`).
**Note: No backup is made before modifying files. Please make sure your VCS staging area is clean.**
```sh
tf-sdk-migrator migrate [--help] PATH
```The eligibility check will be run first: migration will not proceed if this check fails.
The migration tool will then make the following changes:
- `go.mod`: replace `github.com/hashicorp/terraform` dependency with `github.com/hashicorp/terraform-plugin-sdk`
- rewrite import paths in all provider `.go` files (except in `vendor/`) accordingly
- run `go mod tidy`If you use vendored Go dependencies, you should run `go mod vendor` afterwards.
## `tf-sdk-migrator v2upgrade`: migrate from SDKv1 to SDKv2
Migrates a Terraform provider using version 1.x of the standalone SDK to version 2.x of the standalone SDK, updating package import paths.
```sh
tf-sdk-migrator v2upgrade
```Optionally, `--sdk-version` may be passed, which is parsed as a Go module release version. For example `tf-sdk-migrator v2upgrade --sdk-version v2.0.0-rc.1`.
This command rewrites `go.mod` and updates package import paths, but does not replace deprecated identifiers, so it is likely that the provider will not compile after upgrading. Please follow the steps in the [Terraform Plugin SDK v2 Upgrade Guide](https://terraform.io/docs/extend/guides/v2-upgrade-guide.html) after running this command.