|
| 1 | +--- |
| 2 | +title: How to update to Terraform 13 |
| 3 | +categories: Upgrades |
| 4 | +image: /assets/img/guides/refresh_icon.png |
| 5 | +excerpt: Learn how to update the Gruntwork Reference Architecture and your infrastructure code that depends on the Gruntwork Infrastructure as Code Library to Terraform 0.13. |
| 6 | +tags: ["aws", "terraform", "terragrunt"] |
| 7 | +cloud: ["aws"] |
| 8 | +redirect_from: /static/guides/upgrades/how-to-update-to-terraform-13/ |
| 9 | +--- |
| 10 | +:page-type: guide |
| 11 | +:page-layout: post |
| 12 | + |
| 13 | +:toc: |
| 14 | +:toc-placement!: |
| 15 | + |
| 16 | +// GitHub specific settings. See https://gist.github.com/dcode/0cfbf2699a1fe9b46ff04c41721dda74 for details. |
| 17 | +ifdef::env-github[] |
| 18 | +:tip-caption: :bulb: |
| 19 | +:note-caption: :information_source: |
| 20 | +:important-caption: :heavy_exclamation_mark: |
| 21 | +:caution-caption: :fire: |
| 22 | +:warning-caption: :warning: |
| 23 | +toc::[] |
| 24 | +endif::[] |
| 25 | + |
| 26 | +== Intro |
| 27 | + |
| 28 | +This guide will walk you through how to update the https://gruntwork.io/reference-architecture/[Gruntwork Reference |
| 29 | +Architecture] and any code that depends on the |
| 30 | +https://gruntwork.io/infrastructure-as-code-library/[Gruntwork Infrastructure as Code Library] to |
| 31 | +https://www.terraform.io/upgrade-guides/0-13.html[Terraform 0.13]. Terraform 0.13 introduces a number of new features |
| 32 | +and fixes, but it also has a number of backwards incompatibilities that have to be incorporated into your codebase. |
| 33 | + |
| 34 | +=== What you'll learn in this guide |
| 35 | + |
| 36 | +This guide consists of three main sections: |
| 37 | + |
| 38 | +<<core_concepts>>:: |
| 39 | + An overview of Terraform 0.13 and why it is important to update your code for compatibility. |
| 40 | + |
| 41 | +<<deployment_walkthrough>>:: |
| 42 | + The steps you need to take to update your code relying on the Gruntwork Infrastructure as Code library and your |
| 43 | + version of the Gruntwork Reference Architecture to work with Terraform 0.13. Includes a |
| 44 | + <<compatibility_table,version compatibility table>> you can use as a reference to know which Gruntwork Repo version |
| 45 | + tag is compatible with Terraform 0.13. |
| 46 | + |
| 47 | + |
| 48 | +[[core_concepts]] |
| 49 | +== Core Concepts |
| 50 | + |
| 51 | +=== Background |
| 52 | + |
| 53 | +https://www.hashicorp.com/blog/announcing-hashicorp-terraform-0-13[Terraform 0.13 was released on August 10th, 2020]. |
| 54 | +Some of the major new features in 0.13 include: |
| 55 | + |
| 56 | +. The ability to use `count`, `for_each`, and `depends_on` with modules. |
| 57 | +. A new `required_providers` block that makes it much easier to work with third-party providers. |
| 58 | +. Custom variable validation. |
| 59 | + |
| 60 | +For more info, check out the https://www.hashicorp.com/blog/announcing-hashicorp-terraform-0-13[announcement blog post]. |
| 61 | + |
| 62 | +0.13 is a major new release for Terraform, which means it includes a number of backwards incompatible changes. We have |
| 63 | +gone through all the Terraform modules in the https://gruntwork.io/infrastructure-as-code-library/[Gruntwork |
| 64 | +Infrastructure as Code Library] and updated them to work with Terraform 0.13. In order to use 0.13, you will need to |
| 65 | +update to these new versions and make other changes to your code, as described in the following section. |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +[[deployment_walkthrough]] |
| 70 | +== Deployment walkthrough |
| 71 | + |
| 72 | +=== Step 1: update your code to be compatible with Terraform 0.12 |
| 73 | + |
| 74 | +If you haven't already, you need to: |
| 75 | + |
| 76 | +. Update your code to work with Terraform 0.12. Do NOT skip from, say, 0.11, straight to 0.13. You MUST update to |
| 77 | + 0.12.26 or above first! If you're still on Terraform 0.11 or older, see our |
| 78 | + https://docs.gruntwork.io/guides/upgrading-to-tf12-tg19/[Terraform 0.12 upgrade guide] for instructions. |
| 79 | +. Update all your Gruntwork modules to the latest versions just _before_ the TF 0.13 versions in the compatibility |
| 80 | + table below. The upgrade will be much easier and less error prone if you keep the number of version jumps as small |
| 81 | + as possible. |
| 82 | + |
| 83 | +=== Step 2: update your code to be compatible with Terraform 0.13 |
| 84 | + |
| 85 | +The first step is to update your own code (e.g., the code that lives in your `infrastructure-modules` repo) to be |
| 86 | +compatible with Terraform 0.13 by following HashiCorp's https://www.terraform.io/upgrade-guides/0-13.html[Terraform 0.13 |
| 87 | +Upgrade Guide]. |
| 88 | + |
| 89 | +=== Step 3: update references to the Gruntwork Infrastructure as Code Library |
| 90 | + |
| 91 | +In order to take advantage of the Terraform 0.13, you need to update your references to the Gruntwork |
| 92 | +Infrastructure as Code Library to use a compatible version. We (Gruntwork) have gone through all our modules in the |
| 93 | +library to test and update the code to be compatible with Terraform 0.13. As a customer, you need to update to |
| 94 | +the proper versions of the Gruntwork library to pick up the fixes/changes that were made to be compatible. Refer to |
| 95 | +https://gruntwork.io/guides/foundations/how-to-use-gruntwork-infrastructure-as-code-library/#updating[the |
| 96 | +"Updating" section of "How to use the Gruntwork Infrastructure as Code Library"] for instructions on how to update the |
| 97 | +versions in your code. |
| 98 | + |
| 99 | +For the vast majority of the repos, the only change that will be necessary is a version number bump, but several repos |
| 100 | +require more extensive code changes and state migrations. To upgrade without downtime and data loss, **you MUST follow |
| 101 | +the migration instructions in the release notes in each repo to know what changes need to be made to update to the new |
| 102 | +version.** The repo most affected by the 0.13 backward incompatibilities was `terraform-aws-eks`, so if you are an EKS |
| 103 | +user, pay special attention to the release notes! |
| 104 | + |
| 105 | +[.exceptional] |
| 106 | +IMPORTANT: Gruntwork follows |
| 107 | +https://gruntwork.io/guides/foundations/how-to-use-gruntwork-infrastructure-as-code-library/#versioning[semantic |
| 108 | +versioning]. For any pre-1.0 modules, this means that version updates to the minor version are considered backwards |
| 109 | +incompatible releases for any version updates prior to 1.0.0 release. Make sure to read the release notes for the |
| 110 | +relevant modules any time you are updating minor versions! Note that you will want to read the release notes for each |
| 111 | +minor version that is updated (e.g., if you are going from v0.5.x to v0.9.x, you will want to read the notes for v0.6.0, |
| 112 | +v0.7.0, v0.8.0, and v0.9.0 to get the full list of backwards incompatible updates). |
| 113 | + |
| 114 | +The following table provides a summary of all the relevant Gruntwork AWS modules and the respective versions that are |
| 115 | +compatible with Terraform 0.13: |
| 116 | + |
| 117 | +[[compatibility_table]] |
| 118 | +[cols="1,1h"] |
| 119 | +|=== |
| 120 | +|Gruntwork Repo |Minimum version with Terraform 0.13 support |
| 121 | + |
| 122 | +|Terratest |
| 123 | +|https://github.com/gruntwork-io/terratest/releases/tag/v0.30.0[v0.30.0] |
| 124 | + |
| 125 | +|Terragrunt |
| 126 | +|https://github.com/gruntwork-io/terragrunt/releases/tag/v0.25.4[v0.25.4] |
| 127 | + |
| 128 | +|package-terraform-utilities |
| 129 | +|https://github.com/gruntwork-io/package-terraform-utilities/releases/tag/v0.3.0[v0.3.0] |
| 130 | + |
| 131 | +|terraform-aws-vpc |
| 132 | +|https://github.com/gruntwork-io/terraform-aws-vpc/releases/tag/v0.10.0[v0.10.0] |
| 133 | + |
| 134 | +|module-asg |
| 135 | +|https://github.com/gruntwork-io/module-asg/releases/tag/v0.11.0[v0.11.0] |
| 136 | + |
| 137 | +|module-server |
| 138 | +|https://github.com/gruntwork-io/module-server/releases/tag/v0.9.0[v0.9.0] |
| 139 | + |
| 140 | +|package-lambda |
| 141 | +|https://github.com/gruntwork-io/package-lambda/releases/tag/v0.9.0[v0.9.0] |
| 142 | + |
| 143 | +|module-security |
| 144 | +|https://github.com/gruntwork-io/module-security/releases/tag/v0.37.0[v0.37.0] |
| 145 | + |
| 146 | +|module-load-balancer |
| 147 | +|https://github.com/gruntwork-io/module-load-balancer/releases/tag/v0.21.0[v0.21.0] |
| 148 | + |
| 149 | +|module-data-storage |
| 150 | +|https://github.com/gruntwork-io/module-data-storage/releases/tag/v0.16.0[v0.16.0] |
| 151 | + |
| 152 | +|module-cache |
| 153 | +|https://github.com/gruntwork-io/module-cache/releases/tag/v0.10.0[v0.10.0] |
| 154 | + |
| 155 | +|package-messaging |
| 156 | +|https://github.com/gruntwork-io/package-messaging/releases/tag/v0.4.0[v0.4.0] |
| 157 | + |
| 158 | +|package-static-assets |
| 159 | +|https://github.com/gruntwork-io/package-static-assets/releases/tag/v0.7.0[v0.7.0] |
| 160 | + |
| 161 | +|terraform-aws-monitoring |
| 162 | +|https://github.com/gruntwork-io/terraform-aws-monitoring/releases/tag/v0.23.0[v0.23.0] |
| 163 | + |
| 164 | +|package-openvpn |
| 165 | +|https://github.com/gruntwork-io/package-openvpn/releases/tag/v0.12.0[v0.12.0] |
| 166 | + |
| 167 | +|module-ecs |
| 168 | +|https://github.com/gruntwork-io/module-ecs/releases/tag/v0.23.0[v0.23.0] |
| 169 | + |
| 170 | +|module-ci |
| 171 | +|https://github.com/gruntwork-io/module-ci/releases/tag/v0.29.0[v0.29.0] |
| 172 | + |
| 173 | +|terraform-aws-eks |
| 174 | +|https://github.com/gruntwork-io/terraform-aws-eks/releases/tag/v0.30.0[v0.30.0] |
| 175 | + |
| 176 | +|package-zookeeper |
| 177 | +|https://github.com/gruntwork-io/package-zookeeper/releases/tag/v0.7.0[v0.7.0] |
| 178 | + |
| 179 | +|package-kafka |
| 180 | +|https://github.com/gruntwork-io/package-kafka/releases/tag/v0.7.0[v0.7.0] |
| 181 | + |
| 182 | +|package-elk |
| 183 | +|https://github.com/gruntwork-io/package-elk/releases/tag/v0.7.0[v0.7.0] |
| 184 | + |
| 185 | +|terraform-kubernetes-helm |
| 186 | +|Deprecated. Migrate to `terraform-kubernetes-namespace` instead. |
| 187 | + |
| 188 | +|terraform-kubernetes-namespace |
| 189 | +|https://github.com/gruntwork-io/terraform-kubernetes-namespace/releases/tag/v0.1.0[v0.1.0] |
| 190 | + |
| 191 | +|cis-compliance-aws |
| 192 | +|https://github.com/gruntwork-io/cis-compliance-aws/releases/tag/v0.9.0[v0.9.0] |
| 193 | + |
| 194 | +|package-sam |
| 195 | +|https://github.com/gruntwork-io/package-sam/releases/tag/v0.3.0[v0.3.0] |
| 196 | + |
| 197 | +|terraform-aws-couchbase |
| 198 | +|https://github.com/gruntwork-io/terraform-aws-couchbase/releases/tag/v0.4.0[v0.4.0] |
| 199 | + |
| 200 | +|terraform-aws-influx |
| 201 | +|https://github.com/gruntwork-io/terraform-aws-influx/releases/tag/v0.2.0[v0.2.0] |
| 202 | + |
| 203 | +|terraform-aws-consul |
| 204 | +|https://github.com/hashicorp/terraform-aws-consul/releases/tag/v0.8.0[v0.8.0] |
| 205 | + |
| 206 | +|terraform-aws-vault |
| 207 | +|https://github.com/hashicorp/terraform-aws-vault/releases/tag/v0.14.0[v0.14.0] |
| 208 | + |
| 209 | +|terraform-aws-nomad |
| 210 | +|https://github.com/hashicorp/terraform-aws-nomad/releases/tag/v0.7.0[v0.7.0] |
| 211 | + |
| 212 | +|=== |
| 213 | + |
| 214 | + |
| 215 | +=== Updating the Gruntwork Reference Architecture to Terraform 0.13 |
| 216 | + |
| 217 | +If you purchased the Gruntwork Reference Architecture, you will have a copy of the `infrastructure-live` and |
| 218 | +`infrastructure-modules` repositories that contain the infrastructure code for deploying the Reference Architecture. You |
| 219 | +will need to update the relevant code in `infrastructure-modules` to use a compatible version of the |
| 220 | +Gruntwork Infrastructure as Code Library, as per <<compatibility_table,the compatibility table>> above. |
| 221 | + |
| 222 | + |
| 223 | +To help guide you through the upgrade process, we have updated the Acme Reference Architecture examples to support |
| 224 | +Terraform 0.13. You can refer to the pull requests to see an example of the updates you'lll need to do to make your |
| 225 | +Reference Architecture work with Terraform 0.13: |
| 226 | + |
| 227 | +Standard Reference Architecture:: |
| 228 | + See the https://github.com/gruntwork-io/infrastructure-modules-multi-account-acme/pull/46[infrastructure-modules PR] |
| 229 | + and the https://github.com/gruntwork-io/infrastructure-live-multi-account-acme/pull/44[infrastructure-live PR] for |
| 230 | + an example of a Terraform 0.13 update. |
| 231 | + |
| 232 | +CIS Reference Architecture:: |
| 233 | + See the https://github.com/gruntwork-io/cis-infrastructure-modules-acme/pull/5[infrastructure-modules PR] |
| 234 | + and the https://github.com/gruntwork-io/cis-infrastructure-live-acme/pull/7[infrastructure-live PR] for |
| 235 | + an example of a Terraform 0.13 update for the CIS components of the Reference Architecture. For all other components, |
| 236 | + refer to PRs in the Standard Reference Architecture section above. |
| 237 | + |
| 238 | + |
0 commit comments