Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump terraform version from 1.3.10 to 1.5.7 #1268

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 0-bootstrap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FROM gcr.io/cloud-builders/gcloud-slim

# Use ARG so that values can be overriden by user/cloudbuild
ARG TERRAFORM_VERSION=1.3.10
ARG TERRAFORM_VERSION=1.5.7

ENV ENV_TERRAFORM_VERSION=$TERRAFORM_VERSION

Expand Down
38 changes: 37 additions & 1 deletion 0-bootstrap/README-GitHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,43 @@ To run the instructions described in this document, install the following:
- [Google Cloud SDK](https://cloud.google.com/sdk/install) version 393.0.0 or later
- [terraform-tools](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) component
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) version 2.28.0 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.3.10 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.5.7 or later

For the manual steps described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

Version 1.5.7 is the last version before the license model change. To use a later version of Terraform, ensure that the Terraform version used in the Operational System to manually execute part of the steps in `3-networks` and `4-projects` is the same version configured in the following code

- 0-bootstrap/modules/jenkins-agent/variables.tf
```
default = "1.5.7"
```

- 0-bootstrap/cb.tf
```
terraform_version = "1.5.7"
```

- scripts/validate-requirements.sh
```
TF_VERSION="1.5.7"
```

- build/github-tf-apply.yaml
```
terraform_version: '1.5.7'
```

- github-tf-pull-request.yaml

```
terraform_version: "1.5.7"
```

- 0-bootstrap/Dockerfile
```
ARG TERRAFORM_VERSION=1.5.7
```

Also make sure that you have the following:

Expand Down
38 changes: 37 additions & 1 deletion 0-bootstrap/README-GitLab.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,45 @@ To run the instructions described in this document, install the following:
- [Google Cloud SDK](https://cloud.google.com/sdk/install) version 393.0.0 or later
- [terraform-tools](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) component
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) version 2.28.0 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.3.10 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.5.7 or later
- [jq](https://jqlang.github.io/jq/) version 1.6 or later.

For the manual steps described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

Version 1.5.7 is the last version before the license model change. To use a later version of Terraform, ensure that the Terraform version used in the Operational System to manually execute part of the steps in `3-networks` and `4-projects` is the same version configured in the following code

- 0-bootstrap/modules/jenkins-agent/variables.tf
```
default = "1.5.7"
```

- 0-bootstrap/cb.tf
```
terraform_version = "1.5.7"
```

- scripts/validate-requirements.sh
```
TF_VERSION="1.5.7"
```

- build/github-tf-apply.yaml
```
terraform_version: '1.5.7'
```

- github-tf-pull-request.yaml

```
terraform_version: "1.5.7"
```

- 0-bootstrap/Dockerfile
```
ARG TERRAFORM_VERSION=1.5.7
```

Also make sure that you have the following:

- A [GitLab](https://docs.gitlab.com/ee/user/profile/account/create_accounts.html) account for your User or Group.
Expand Down
41 changes: 39 additions & 2 deletions 0-bootstrap/README-Jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,46 @@ You arrived to these instructions because you are using the `jenkins_bootstrap`
### II. Create the SEED and CI/CD projects using Terraform

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

For the manual steps described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

Version 1.5.7 is the last version before the license model change. To use a later version of Terraform, ensure that the Terraform version used in the Operational System to manually execute part of the steps in `3-networks` and `4-projects` is the same version configured in the following code

- 0-bootstrap/modules/jenkins-agent/variables.tf
```
default = "1.5.7"
```

- 0-bootstrap/cb.tf
```
terraform_version = "1.5.7"
```

- scripts/validate-requirements.sh
```
TF_VERSION="1.5.7"
```

- build/github-tf-apply.yaml
```
terraform_version: '1.5.7'
```

- github-tf-pull-request.yaml

```
terraform_version: "1.5.7"
```

- 0-bootstrap/Dockerfile
```
ARG TERRAFORM_VERSION=1.5.7
```


1. Get the appropriate credentials: run the following command with an account that has the [necessary permissions](./modules/jenkins-agent/README.md#permissions).

```bash
Expand All @@ -209,7 +246,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)
- **Use Terraform 1.3.10** to run the terraform script with the commands below
- **Use Terraform 1.5.7** to run the terraform script with the commands below

```bash
terraform init
Expand Down
5 changes: 4 additions & 1 deletion 0-bootstrap/README-Terraform-Cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ To run the instructions described in this document, install the following:
- [Google Cloud SDK](https://cloud.google.com/sdk/install) version 393.0.0 or later
- [terraform-tools](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) component
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) version 2.28.0 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.3.10 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.5.7 or later
- [jq](https://jqlang.github.io/jq/download/) version 1.6.0 or later

For the manual steps described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

Also make sure that you have the following:

- A [Terraform Cloud account](https://developer.hashicorp.com/terraform/tutorials/cloud-get-started/cloud-sign-up#create-an-account) for your User or [Organization](https://developer.hashicorp.com/terraform/tutorials/cloud-get-started/cloud-sign-up#create-an-organization).
Expand Down
37 changes: 35 additions & 2 deletions 0-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,43 @@ To run the commands described in this document, install the following:

- [Google Cloud SDK](https://cloud.google.com/sdk/install) version 393.0.0 or later
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) version 2.28.0 or later
- [Terraform](https://www.terraform.io/downloads.html) version 1.3.10
- [Terraform](https://www.terraform.io/downloads.html) version 1.5.7
- [jq](https://jqlang.github.io/jq/download/) version 1.6.0 or later

**Note:** Make sure that you use version 1.3.10 of Terraform throughout this series. Otherwise, you might experience Terraform state snapshot lock errors.
**Note:** Make sure that you use the same version of [Terraform](https://www.terraform.io/downloads.html) throughout this series. Otherwise, you might experience Terraform state snapshot lock errors.

Version 1.5.7 is the last version before the license model change. To use a later version of Terraform, ensure that the Terraform version used in the Operational System to manually execute part of the steps in `3-networks` and `4-projects` is the same version configured in the following code

- 0-bootstrap/modules/jenkins-agent/variables.tf
```
default = "1.5.7"
```

- 0-bootstrap/cb.tf
```
terraform_version = "1.5.7"
```

- scripts/validate-requirements.sh
```
TF_VERSION="1.5.7"
```

- build/github-tf-apply.yaml
```
terraform_version: '1.5.7'
```

- github-tf-pull-request.yaml

```
terraform_version: "1.5.7"
```

- 0-bootstrap/Dockerfile
```
ARG TERRAFORM_VERSION=1.5.7
```

Also make sure that you've done the following:

Expand Down
2 changes: 1 addition & 1 deletion 0-bootstrap/cb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

locals {
// terraform version image configuration
terraform_version = "1.3.10"
terraform_version = "1.5.7"
// The version of the terraform docker image to be used in the workspace builds
docker_tag_version_terraform = "v1"

Expand Down
6 changes: 3 additions & 3 deletions 0-bootstrap/modules/jenkins-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module "jenkins_bootstrap" {
| storage\_bucket\_prefix | Name prefix to use for storage buckets. | `string` | `"bkt"` | no |
| terraform\_sa\_names | Fully-qualified name of the Terraform Service Accounts. It must be supplied by the Seed Project | `map(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` | `"1.3.10"` | no |
| terraform\_version | Default terraform version. | `string` | `"1.5.7"` | no |
| terraform\_version\_sha256sum | sha256sum for default terraform version. | `string` | `"380ca822883176af928c80e5771d1c0ac9d69b13c6d746e6202482aedde7d457"` | 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 |
Expand All @@ -103,8 +103,8 @@ module "jenkins_bootstrap" {
### Software

- [gcloud sdk](https://cloud.google.com/sdk/install) >= 393.0.0
- [Terraform](https://www.terraform.io/downloads.html) = 1.3.10
- The scripts in this codebase use Terraform v1.3.10. 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) = 1.5.7
- The scripts in this codebase use Terraform v1.5.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
2 changes: 1 addition & 1 deletion 0-bootstrap/modules/jenkins-agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ variable "folder_id" {
variable "terraform_version" {
description = "Default terraform version."
type = string
default = "1.3.10"
default = "1.5.7"
}

variable "terraform_version_sha256sum" {
Expand Down
5 changes: 2 additions & 3 deletions 3-networks-dual-svpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ The purpose of this step is to:
echo "access_context_manager_policy_id = ${ACCESS_CONTEXT_MANAGER_ID}"
```

1. For the manual step described in this document, you need [Terraform](https://www.terraform.io/downloads.html) version 1.3.10 or later to be installed.

**Note:** Make sure that you use version 1.3.10 or later of Terraform throughout this series. Otherwise, you might experience Terraform state snapshot lock errors.
1. For the manual step described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

### Troubleshooting

Expand Down
5 changes: 2 additions & 3 deletions 3-networks-hub-and-spoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ The purpose of this step is to:
echo "access_context_manager_policy_id = ${ACCESS_CONTEXT_MANAGER_ID}"
```

1. For the manual step described in this document, you need [Terraform](https://www.terraform.io/downloads.html) version 1.3.10 or later to be installed.

**Note:** Make sure that you use version 1.3.10 or later of Terraform throughout this series. Otherwise, you might experience Terraform state snapshot lock errors.
1. For the manual step described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

### Troubleshooting

Expand Down
7 changes: 3 additions & 4 deletions 4-projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ Other Workspaces can also be created to isolate deployments if needed.
1. 2-environments executed successfully.
1. 3-networks executed successfully.

1. For the manual step described in this document, you need [Terraform](https://www.terraform.io/downloads.html) version 1.3.10 or later to be installed.
1. For the manual step described in this document, you need to use the same [Terraform](https://www.terraform.io/downloads.html) version used on the build pipeline.
Otherwise, you might experience Terraform state snapshot lock errors.

**Note:** Make sure that you use version 1.3.10 or later of Terraform throughout this series. Otherwise, you might experience Terraform state snapshot lock errors.

**Note 2:** As mentioned in 0-bootstrap [README note 2](../0-bootstrap/README.md#deploying-with-cloud-build) at the end of Cloud Build deploy section, make sure that you have requested at least 50 additional projects for the **projects step service account**, otherwise you may face a project quota exceeded error message during the following steps and you will need to apply the fix from [this entry](../docs/TROUBLESHOOTING.md#attempt-to-run-4-projects-step-without-enough-project-quota) of the Troubleshooting guide in order to continue.
**Note:** As mentioned in 0-bootstrap [README note 2](../0-bootstrap/README.md#deploying-with-cloud-build) at the end of Cloud Build deploy section, make sure that you have requested at least 50 additional projects for the **projects step service account**, otherwise you may face a project quota exceeded error message during the following steps and you will need to apply the fix from [this entry](../docs/TROUBLESHOOTING.md#attempt-to-run-4-projects-step-without-enough-project-quota) of the Troubleshooting guide in order to continue.

### Troubleshooting

Expand Down
2 changes: 1 addition & 1 deletion build/github-tf-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

- uses: 'hashicorp/setup-terraform@v2'
with:
terraform_version: '1.3'
terraform_version: '1.5.7'

- id: setup
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion build/github-tf-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- uses: "hashicorp/setup-terraform@v2"
with:
terraform_version: "1.3"
terraform_version: "1.5.7"

- id: setup
shell: bash
Expand Down
12 changes: 6 additions & 6 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,37 @@ This could be due to init.defaultBranch being set to something other than
When running the build for the branch `production` in step 3-networks in your **Foundation CI/CD Pipeline** the build fails with:

```
state snapshot was created by Terraform v1.x.x, which is newer than current v1.3.10; upgrade to Terraform v1.x.x or greater to work with this state
state snapshot was created by Terraform v1.x.x, which is newer than current v1.5.7; upgrade to Terraform v1.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 executed with a Terraform version newer than version v1.3.10 used in the **Foundation CI/CD 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 v1.5.7 used in the **Foundation CI/CD 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 v1.3.10.
You will need to re-run the deploy of the 3-networks shared environment with Terraform v1.5.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 v1.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 v1.3.10.
- Re-run the manual deploy of 3-networks shared environment using Terraform v1.3.10.
- Install Terraform v1.5.7.
- Re-run the manual deploy of 3-networks shared environment using Terraform v1.5.7.

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

Replace `1.x.x` with the actual version of your local Terraform version in the following instructions:

- Go to folder `0-bootstrap`.
- Edit the local `terraform_version` in the Terraform [cb.tf](../0-bootstrap/cb.tf) file:
- Upgrade local `terraform_version` from `"1.3.10"` to `"1.x.x"`
- Upgrade local `terraform_version` from `"1.5.7"` to `"1.x.x"`
- Run `terraform init`.
- Run `terraform plan` and review the output.
- Run `terraform apply`.
Expand Down
Loading