Skip to content

Commit

Permalink
updates necessary to upgrade Terraform to v0.13.6
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsleycj committed Apr 29, 2021
1 parent 4a8cbfa commit 7c8bfbe
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 7 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,52 @@
# CHANGELOG

## v5.0.1.3

The purpose of this update is to upgrade Terraform to v0.13.6 on existing
deployments of Cumulus v5.0.1. Cumulus notes for upgrading Terraform are
available [here](https://github.com/nasa/cumulus/blob/master/docs/upgrade-notes/upgrading-tf-version-0.13.6.md).

This CIRRUS update takes care of the running of the `0.13upgrade` command across
all modules. It resulted in the creation of a versions.tf file in each module
and a syntax change to the `required_providers` section in the main.tf file in
each module.

### Prerequisites

* Upgrade your CIRRUS-core release to v5.0.1.2 across all your environments.
* Per the Cumulus notes, apply any configuration across all environments.

### Upgrade Steps

* Review the changes in CIRRUS-DAAC. Add the versions.tf file and update the
`required_providers` section of the main.tf file in your `daac` and `workflows` modules
* In CIRRUS-core run `make image` to create a new Docker `cirrus-core` image with
Terraform 0.13.6.
* Run `make container-shell` - all the following commands are run from inside the
container.
* use the `source env.sh ...` command to set up your environment variables for
the deployment you will be upgrading.
* For each module run `make plan-modulename` (`make plan-tf`, `make plan-daac`, etc).
Only `make plan-tf` will succeed the first time. Even though unsuccessul, this step
is necessary as it runs the `terraform init --reconfigure` mentioned in the Cumulus
upgrade instructions.
* cd to the module directory and run the necessary `terraform state replace-provider`
commands to resolve the issues noted in the `plan` failure.
* Run `make plan-module` again to confirm the issues are resolved

The `scripts/cumulus-v5.0.1-tf-upgrade/replace_tf_providers.sh` script has all
the commands necessary to iterate over each module. **BE WARNED** You may want
to use this as more of a copy-paste guide rather than actually running it. It
does work running end-to-end on my deployments but your mileage may vary. In
particular, you may want to remove the `-auto-approve` switch from the
`terraform state replace-provider` command so you have a chance to review the
changes before accepting them.

* Once all `plans` run successfully you can then run `make modulename` for each
module to complete the upgrade.

The process will need to be repeated for each deployment.

## v5.0.1.2

* Expose elasticsearch configuration parameters in both data-persistence and cumulus modules.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FROM amazonlinux:2
# * Terraform

ENV NODE_VERSION "12.x"
ENV TERRAFORM_VERSION "0.12.18"
ENV TERRAFORM_VERSION "0.13.6"

# Add NodeJS and Yarn repos & update package index
RUN \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endef

# ---------------------------
image: Dockerfile
docker build -f Dockerfile -t cirrus-core .
docker build -f Dockerfile --no-cache -t cirrus-core .

container-shell:
docker run -it --rm \
Expand Down
10 changes: 8 additions & 2 deletions cumulus/common.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
terraform {
required_providers {
aws = "~> 3.19.0"
null = "~> 2.1"
aws = {
source = "hashicorp/aws"
version = "~> 3.19.0"
}
null = {
source = "hashicorp/null"
version = "~> 2.1"
}
}
backend "s3" {
}
Expand Down
3 changes: 3 additions & 0 deletions cumulus/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.13"
}
10 changes: 8 additions & 2 deletions data-persistence/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
terraform {
required_providers {
aws = "~> 3.19.0"
null = "~> 2.1.0"
aws = {
source = "hashicorp/aws"
version = "~> 3.19.0"
}
null = {
source = "hashicorp/null"
version = "~> 2.1.0"
}
}
backend "s3" {
}
Expand Down
3 changes: 3 additions & 0 deletions data-persistence/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.13"
}
54 changes: 54 additions & 0 deletions scripts/cumulus-v5.0.1-tf-upgrade/replace_tf_providers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# These commands are necessary to replace the providers, the plan-*** must be
# run first to download new provider plugins, but it will fail. Then the
# replace-provider commands can be run. Finally re-run the plan and it will
# succeed

# must be done for each DEPLOY_NAME - MATURITY combo

cd /CIRRUS-core

make plan-tf

make plan-daac

cd /CIRRUS-DAAC/daac

terraform state replace-provider -auto-approve registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws
terraform state replace-provider -auto-approve registry.terraform.io/-/archive registry.terraform.io/hashicorp/archive
terraform state replace-provider -auto-approve registry.terraform.io/-/null registry.terraform.io/hashicorp/null

cd /CIRRUS-core

make plan-daac

make plan-data-persistence

cd /CIRRUS-core/data-persistence

terraform state replace-provider -auto-approve registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws

cd /CIRRUS-core

make plan-data-persistence

make plan-cumulus

cd /CIRRUS-core/cumulus

terraform state replace-provider -auto-approve registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws

cd /CIRRUS-core

make plan-cumulus

make plan-workflows

cd /CIRRUS-DAAC/workflows

terraform state replace-provider -auto-approve registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws

cd /CIRRUS-core

make plan-workflows
5 changes: 4 additions & 1 deletion tf/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
terraform {
required_providers {
aws = "~> 3.19.0"
aws = {
source = "hashicorp/aws"
version = "~> 3.19.0"
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions tf/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.13"
}

0 comments on commit 7c8bfbe

Please sign in to comment.