Skip to content

Commit

Permalink
fix: upgrade terraform to 0.13.7 (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
vovinacci committed Jun 23, 2021
1 parent ada64bc commit a9150a7
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions 0-bootstrap/README-Jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ You arrived to these instructions because you are using the `jenkins_bootstrap`
### II. Create the SEED and CICD projects using Terraform

- Required information:
- Terraform version 0.13.6 - See [Requirements](#requirements) section for more details.
- Terraform version 0.13.7 - See [Requirements](#requirements) section for more details.
- The `terraform.tfvars` file with all the necessary values.

1. Get the appropriate credentials: run the following command with an account that has the [necessary permissions](./modules/jenkins-agent/README.md#Permissions).
Expand All @@ -135,7 +135,7 @@ You arrived to these instructions because you are using the `jenkins_bootstrap`
1. Run terraform commands.
- After the credentials are configured, we will create the `prj-b-seed` project (which contains the GCS state bucket and Terraform custom service account) and the `prj-b-cicd` project (which contains the Jenkins Agent, its custom service account and where we will add VPN configuration)
- **WARNING: Make sure you have commented-out the `cloudbuild_bootstrap` module and enabled the `jenkins_bootstrap` module in the `./main.tf` file**
- **Use Terraform 0.13.6** to run the terraform script with the commands below
- **Use Terraform 0.13.7** to run the terraform script with the commands below
```
terraform init
terraform plan
Expand Down
2 changes: 1 addition & 1 deletion 0-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ To run the commands described in this document, you need to have the following
installed:

- The [Google Cloud SDK](https://cloud.google.com/sdk/install) version 319.0.0 or later
- [Terraform](https://www.terraform.io/downloads.html) version 0.13.6.
- [Terraform](https://www.terraform.io/downloads.html) version 0.13.7.
- An existing project which the user has access to be used by terraform-validator.

**Note:** Make sure that you use the same version of Terraform throughout this
Expand Down
4 changes: 2 additions & 2 deletions 0-bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ module "cloudbuild_bootstrap" {
project_prefix = var.project_prefix
cloud_source_repos = var.cloud_source_repos
terraform_validator_release = "2021-03-22"
terraform_version = "0.13.6"
terraform_version_sha256sum = "55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9"
terraform_version = "0.13.7"
terraform_version_sha256sum = "4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957"

activate_apis = [
"serviceusage.googleapis.com",
Expand Down
8 changes: 4 additions & 4 deletions 0-bootstrap/modules/jenkins-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ module "jenkins_bootstrap" {
| terraform\_sa\_name | Fully-qualified name of the terraform service account. It must be supplied by the seed project | `string` | n/a | yes |
| terraform\_service\_account | Email for terraform service account. It must be supplied by the seed project | `string` | n/a | yes |
| terraform\_state\_bucket | Default state bucket, used in Cloud Build substitutions. It must be supplied by the seed project | `string` | n/a | yes |
| terraform\_version | Default terraform version. | `string` | `"0.13.6"` | no |
| terraform\_version\_sha256sum | sha256sum for default terraform version. | `string` | `"55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9"` | no |
| terraform\_version | Default terraform version. | `string` | `"0.13.7"` | no |
| terraform\_version\_sha256sum | sha256sum for default terraform version. | `string` | `"4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957"` | no |
| tunnel0\_bgp\_peer\_address | BGP peer address for tunnel 0 | `string` | n/a | yes |
| tunnel0\_bgp\_session\_range | BGP session range for tunnel 0 | `string` | n/a | yes |
| tunnel1\_bgp\_peer\_address | BGP peer address for tunnel 1 | `string` | n/a | yes |
Expand All @@ -105,8 +105,8 @@ module "jenkins_bootstrap" {
### Software

- [gcloud sdk](https://cloud.google.com/sdk/install) >= 206.0.0
- [Terraform](https://www.terraform.io/downloads.html) = 0.13.6
- The scripts in this codebase use Terraform v0.13.6. You should use the same version in the manual steps to avoid [Terraform State Snapshot Lock](https://github.com/hashicorp/terraform/issues/23290) errors caused by differences in terraform versions.
- [Terraform](https://www.terraform.io/downloads.html) = 0.13.7
- The scripts in this codebase use Terraform v0.13.7. You should use the same version in the manual steps to avoid [Terraform State Snapshot Lock](https://github.com/hashicorp/terraform/issues/23290) errors caused by differences in terraform versions.

### Infrastructure

Expand Down
4 changes: 2 additions & 2 deletions 0-bootstrap/modules/jenkins-agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ variable "folder_id" {
variable "terraform_version" {
description = "Default terraform version."
type = string
default = "0.13.6"
default = "0.13.7"
}

variable "terraform_version_sha256sum" {
description = "sha256sum for default terraform version."
type = string
default = "55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9"
default = "4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957"
}
4 changes: 2 additions & 2 deletions 4-projects/modules/infra_pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| terraform\_apply\_branches | List of git branches configured to run terraform apply Cloud Build trigger. All other branches will run plan by default. | `list(string)` | <pre>[<br> "development",<br> "non-production",<br> "production"<br>]</pre> | no |
| terraform\_validator\_release | Default terraform-validator release. | `string` | `"2021-03-22"` | no |
| terraform\_version | Default terraform version. | `string` | `"0.13.6"` | no |
| terraform\_version\_sha256sum | sha256sum for default terraform version. | `string` | `"55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9"` | no |
| terraform\_version | Default terraform version. | `string` | `"0.13.7"` | no |
| terraform\_version\_sha256sum | sha256sum for default terraform version. | `string` | `"4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957"` | no |

## Outputs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
FROM gcr.io/cloud-builders/gcloud-slim

# Use ARG so that values can be overriden by user/cloudbuild
ARG TERRAFORM_VERSION=0.13.6
ARG TERRAFORM_VERSION_SHA256SUM=55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9
ARG TERRAFORM_VERSION=0.13.7
ARG TERRAFORM_VERSION_SHA256SUM=4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957
ARG TERRAFORM_VALIDATOR_RELEASE=2021-03-22

ENV ENV_TERRAFORM_VERSION=$TERRAFORM_VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ steps:
- name: '${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/terraform'
args: ['version']
substitutions:
_TERRAFORM_VERSION: '0.13.6' # default value
_TERRAFORM_VERSION_SHA256SUM: '55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9' # default value
_TERRAFORM_VERSION: '0.13.7' # default value
_TERRAFORM_VERSION_SHA256SUM: '4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957' # default value
_TERRAFORM_VALIDATOR_RELEASE: '2021-03-22'
images: ['${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/terraform']
4 changes: 2 additions & 2 deletions 4-projects/modules/infra_pipelines/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ variable "cloudbuild_apply_filename" {
variable "terraform_version" {
description = "Default terraform version."
type = string
default = "0.13.6"
default = "0.13.7"
}

variable "terraform_version_sha256sum" {
description = "sha256sum for default terraform version."
type = string
default = "55f2db00b05675026be9c898bdd3e8230ff0c5c78dd12d743ca38032092abfc9"
default = "4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957"
}

variable "terraform_validator_release" {
Expand Down
12 changes: 6 additions & 6 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,29 @@ use the email address of `terraform_service_account` that is created by the Terr
When running the build for the branch `production` in step 3-networks in your **Foundation Pipeline** the build fails with:

```
state snapshot was created by Terraform v0.x.x, which is newer than current v0.13.6; upgrade to Terraform v0.x.x or greater to work with this state
state snapshot was created by Terraform v0.x.x, which is newer than current v0.13.7; upgrade to Terraform v0.x.x or greater to work with this state
```

**Cause:**

The manual deploy step for the shared environment in [3-networks](../3-networks#deploying-with-cloud-build) was execute with a Terraform version newer than version v0.13.6 used in the **Foundation Pipeline**.
The manual deploy step for the shared environment in [3-networks](../3-networks#deploying-with-cloud-build) was executed with a Terraform version newer than version v0.13.7 used in the **Foundation Pipeline**.

**Solution:**

You have two options:

#### Downgrade your local Terraform version

You will need to re-run the deploy of the 3-networks shared environment with Terraform v0.13.6.
You will need to re-run the deploy of the 3-networks shared environment with Terraform v0.13.7.

Steps:

- Go to folder `gcp-networks/envs/shared/`.
- Update `backend.tf` with your bucket name from the 0-bootstrap step.
- Run `terraform destroy` in the folder using the Terraform v0.x.x version.
- Delete the Terraform state file in `gs://YOUR-TF-STATE-BUCKET/terraform/networks/envs/shared/default.tfstate`. This bucket is in your **Seed Project**.
- Install Terraform v0.13.6.
- Re-run the manual deploy of 3-networks shared environment using Terraform v0.13.6.
- Install Terraform v0.13.7.
- Re-run the manual deploy of 3-networks shared environment using Terraform v0.13.7.

#### Upgrade your 0-bootstrap runner image Terraform version

Expand All @@ -89,7 +89,7 @@ Replace `0.x.x` with the actual version of your local Terraform version in the f
- Get the value of the SHA 256 SUM for the amd64 linux version of the release 0.x.x (`terraform_0.x.x_linux_amd64.zip`)
- Go to folder `0-bootstrap`.
- Edit the module `cloudbuild_bootstrap` in the Terraform [main.tf](../0-bootstrap/main.tf) file:
- Upgrade `terraform_version` from `"0.13.6"` to `"0.x.x"`
- Upgrade `terraform_version` from `"0.13.7"` to `"0.x.x"`
- Update `terraform_version_sha256sum` with the value you got from the file `terraform_0.x.x_SHA256SUMS`
- Run `terraform init`.
- Run `terraform plan` and review the output.
Expand Down
2 changes: 1 addition & 1 deletion test/bundle.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
version = "0.13.6"
version = "0.13.7"
}

providers {
Expand Down

0 comments on commit a9150a7

Please sign in to comment.