Last active
September 10, 2020 06:47
-
-
Save nodomain/e190f358181b16e99de8d63fae25510e to your computer and use it in GitHub Desktop.
Terraform 0.13: Replace "namespaceless" providers in state with the HashiCorp namespace variant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform state pull | grep provider | grep registry.terraform.io/- | uniq | cut -d"\\" -f2 | cut -d"\"" -f2 | sort | uniq \ | |
| while IFS= read -r line; do terraform state replace-provider -auto-approve ${line} ${line/-/hashicorp} ; done |
If it is used in a Makefile
then make sure to use $$
instead of $
to correctly expand the 'line' variable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one-liner fixes the providers for Terraform 0.13 in your existing state file.
More background: https://www.terraform.io/upgrade-guides/0-13.html