|
| 1 | +--- |
| 2 | +page_title: "Terraform Google Provider 5.0.0 Upgrade Guide" |
| 3 | +description: |- |
| 4 | + Terraform Google Provider 5.0.0 Upgrade Guide |
| 5 | +--- |
| 6 | + |
| 7 | +# Terraform Google Provider 5.0.0 Upgrade Guide |
| 8 | + |
| 9 | +The `5.0.0` release of the Google provider for Terraform is a major version and |
| 10 | +includes some changes that you will need to consider when upgrading. This guide |
| 11 | +is intended to help with that process and focuses only on the changes necessary |
| 12 | +to upgrade from the final `4.X` series release to `5.0.0`. |
| 13 | + |
| 14 | +Most of the changes outlined in this guide have been previously marked as |
| 15 | +deprecated in the Terraform `plan`/`apply` output throughout previous provider |
| 16 | +releases, up to and including the final `4.X` series release. These changes, |
| 17 | +such as deprecation notices, can always be found in the CHANGELOG of the |
| 18 | +affected providers. [google](https://github.com/hashicorp/terraform-provider-google/blob/main/CHANGELOG.md) |
| 19 | +[google-beta](https://github.com/hashicorp/terraform-provider-google-beta/blob/main/CHANGELOG.md) |
| 20 | + |
| 21 | +## I accidentally upgraded to 5.0.0, how do I downgrade to `4.X`? |
| 22 | + |
| 23 | +If you've inadvertently upgraded to `5.0.0`, first see the |
| 24 | +[Provider Version Configuration Guide](#provider-version-configuration) to lock |
| 25 | +your provider version; if you've constrained the provider to a lower version |
| 26 | +such as shown in the previous version example in that guide, Terraform will pull |
| 27 | +in a `4.X` series release on `terraform init`. |
| 28 | + |
| 29 | +If you've only ran `terraform init` or `terraform plan`, your state will not |
| 30 | +have been modified and downgrading your provider is sufficient. |
| 31 | + |
| 32 | +If you've ran `terraform refresh` or `terraform apply`, Terraform may have made |
| 33 | +state changes in the meantime. |
| 34 | + |
| 35 | +* If you're using a local state, or a remote state backend that does not support |
| 36 | +versioning, `terraform refresh` with a downgraded provider is likely sufficient |
| 37 | +to revert your state. The Google provider generally refreshes most state |
| 38 | +information from the API, and the properties necessary to do so have been left |
| 39 | +unchanged. |
| 40 | + |
| 41 | +* If you're using a remote state backend that supports versioning such as |
| 42 | +[Google Cloud Storage](https://developer.hashicorp.com/terraform/language/settings/backends/gcs), |
| 43 | +you can revert the Terraform state file to a previous version. If you do |
| 44 | +so and Terraform had created resources as part of a `terraform apply` in the |
| 45 | +meantime, you'll need to either delete them by hand or `terraform import` them |
| 46 | +so Terraform knows to manage them. |
| 47 | + |
| 48 | +## Provider Version Configuration |
| 49 | + |
| 50 | +-> Before upgrading to version 5.0.0, it is recommended to upgrade to the most |
| 51 | +recent `4.X` series release of the provider, make the changes noted in this guide, |
| 52 | +and ensure that your environment successfully runs |
| 53 | +[`terraform plan`](https://developer.hashicorp.com/terraform/cli/commands/plan) |
| 54 | +without unexpected changes or deprecation notices. |
| 55 | + |
| 56 | +It is recommended to use [version constraints](https://developer.hashicorp.com/terraform/language/providers/requirements#requiring-providers) |
| 57 | +when configuring Terraform providers. If you are following that recommendation, |
| 58 | +update the version constraints in your Terraform configuration and run |
| 59 | +[`terraform init`](https://developer.hashicorp.com/terraform/cli/commands/init) to download |
| 60 | +the new version. |
| 61 | + |
| 62 | +If you aren't using version constraints, you can use `terraform init -upgrade` |
| 63 | +in order to upgrade your provider to the latest released version. |
| 64 | + |
| 65 | +For example, given this previous configuration: |
| 66 | + |
| 67 | +```hcl |
| 68 | +terraform { |
| 69 | + required_providers { |
| 70 | + google = { |
| 71 | + version = "~> 4.70.0" |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +An updated configuration: |
| 78 | + |
| 79 | +```hcl |
| 80 | +terraform { |
| 81 | + required_providers { |
| 82 | + google = { |
| 83 | + version = "~> 5.0.0" |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +## Provider |
| 90 | + |
| 91 | +### Provider-level change example header |
| 92 | + |
| 93 | +Description of the change and how users should adjust their configuration (if needed). |
| 94 | + |
| 95 | +## Datasources |
| 96 | + |
| 97 | +## Datasource: `google_product_datasource` |
| 98 | + |
| 99 | +### Datasource-level change example header |
| 100 | + |
| 101 | +Description of the change and how users should adjust their configuration (if needed). |
| 102 | + |
| 103 | +## Resources |
| 104 | + |
| 105 | +## Resource: `google_product_resource` |
| 106 | + |
| 107 | +### Resource-level change example header |
| 108 | + |
| 109 | +Description of the change and how users should adjust their configuration (if needed). |
0 commit comments