Gruntwork Newsletter, August 2019

Once a month, we send out a newsletter to all Gruntwork customers that describes all the updates we’ve made in the last month, news in the DevOps industry, and important security updates. Note that many of the links below go to private repos in the Gruntwork Infrastructure as Code Library and Reference Architecture that are only accessible to customers.

Hello Grunts,

In the last month, we updated our AWS Reference Architecture to work with Terraform 0.12 and Terragrunt 0.19, began building a GCP Reference Architecture, released a set of open source modules for running the TICK stack on GCP, made some major improvements to Terragrunt (including the ability to fetch outputs from dependencies!), and lots of other fixes and improvements. Read on for the full details.

As always, if you have any questions or need help, email us at support@gruntwork.io!

Gruntwork Updates

The Reference Architecture has been updated to Terraform 0.12 and Terragrunt 0.19!

Motivation: Last month we announced that all our modules had been upgraded to be compatible with Terraform 0.12. However, we had yet to update the Gruntwork Reference Architecture, which uses all of our modules under the hood, to be compatible with Terraform 0.12.

Solution: We’ve updated the Reference Architecture to be compatible with Terraform 0.12!

What to do about it: The Reference Architecture example repos have now been updated to Terraform 0.12 and Terragrunt 0.19 syntax:

Normally we link you to a diff with the changes that are necessary to update the Reference Architecture code. However, since the change set for this update is huge (see this PR for an example), we instead recommend following our upgrade guide, and using the Acme repos as a reference for what it should look like in the end.

New modules: TICK Stack for GCP

Motivation: We’ve continued working with the InfluxData team to support running their entire time-series platform, known as the TICK stack (Telegraf, InfluxDB, Chronograf, and Kapacitor), in GCP.

Solution: We released the terraform-google-influx module, which is open source on GitHub under the Apache 2.0 License, and available in the Terraform Registry! This module makes it easy to spin up any TICK Stack component in Google Cloud Platform.

What to do about it: Read the release blog post, give the modules a try and let us know how they work for you!

Gruntwork Reference Architecture for GCP

Motivation: In May, in partnership with Google, we open sourced a collection of reusable modules for Google Cloud Platform (GCP), including modules for Kubernetes (GKE), VPCs, Cloud SQL, Cloud Load Balancer, and more. These modules make it much easier to deploy and manage infrastructure on GCP, but wiring all of them together to build your entire tech stack is still a lot of work.

Solution: We are building out an end-to-end, production-grade, secure, and developer-friendly Reference Architecture for GCP! Just as with our AWS Reference Architecture, the GCP Reference Architecture includes just about everything a typical company needs: VPCs, Kubernetes (GKE), load balancers, databases, caches, static content, CI / CD, monitoring, alerting, user and permissions management, VPN, SSH, and so on. We deploy the Reference Architecture into your GCP account and give you 100% of the code, allowing your team to immediately start building on top of a battle-tested, best-practices, fully-automated infrastructure.

What to do about it: The GCP Reference Architecture is currently in private beta. If you’re interested in getting access, Contact Us!

Terragrunt Core Feature Improvements

Motivation: Two months ago we announced Terragrunt 0.19, which introduced a new configuration syntax for the Terragrunt config file. The introduction of this new config file allowed us to upgrade the underlying syntax to HCL2 which has many language level improvements that makes it easy to extend the configuration with additional features.

This month we leveraged this new configuration syntax to address two problems:

Solution: We’ve updated Terragrunt to address these two issues! This month, we introduced two new blocks in Terragrunt: locals and dependency.

locals is a new block that can be used to bind expressions to variables for reuse in your config. Consider the following terragrunt.hcl file:

remote_state {
backend = "s3"
config = {
bucket = "my-terraform-bucket"
region = "us-east-1"
key    = "${path_relative_to_include()}/terraform.tfstate"
}
}
inputs = {
aws_region  = "us-east-1"
s3_endpoint = "com.amazonaws.us-east-1.s3"
}

Here, the region is a hard coded string ("us-east-1") repeated multiple times throughout the config. When switching to a new region, we have to replace that string in all three places. With locals , we can bind the string to a temporary variable:

locals {
region = "us-east-1"
}
remote_state {
backend = "s3"
config = {
bucket = "my-terraform-bucket"
region = local.region
key    = "${path_relative_to_include()}/terraform.tfstate"
}
}
inputs = {
aws_region  = local.region
s3_endpoint = "com.amazonaws.${local.region}.s3"
}

Now you only need to update the region string in one place and the rest of the config will inherit that! You can learn more about locals in the corresponding section of the README.

dependency is a new block that can be used to read in the module outputs of another Terraform module managed using Terragrunt. Consider the following folder structure:

root
├── mysql
│   └── terragrunt.hcl
└── vpc
└── terragrunt.hcl

In most cases, you will most likely want to deploy the database (deployed with the mysql module) into the VPC (deployed with the vpc module). This means that you need to somehow get the VPC ID from the output of the vpc module. Before, your only option was to use terraform_remote_state , which has some downsides: it is encoded in the modules so hard to change, requires strict alignment of terraform versions, to name a few.

Now, you can address this using the new dependency block. In mysql/terragrunt.hcl , you can have the following config to read the vpc_id output of the vpc module:

dependency "vpc" {
config_path = "../vpc"
}

inputs = {
vpc_id = dependency.vpc.outputs.vpc_id
}

This will run terragrunt output on the vpc module and render that as the variable dependency.vpc.outputs , which you can then reference in your inputs. You can learn more about the dependency block in the updated README.

Other Terragrunt updates:

What to do about it: Download the latest version of terragrunt from the releases page and take it for a spin!

Open source updates

Other updates

DevOps News

Terraform 0.12.6 release supports for_each on resources!

What happened: The Terraform 0.12.6 release is out, which includes an long-awaited feature: you can now use for_each with resources!

Why it matters: In order to create multiple resources in Terraform (i.e., similar to a for-loop), your only option was count. E.g., Setting count = 3 on a resource would create 3 copies of that resource. However, once you a set count on a resource, that resource is now a list of resources, and Terraform tracks the identity of each resource based on its position in that list. If you deleted an item from the middle of this list, Terraform would end up shifting all the items after it back by one, effectively deleting and recreating all of those items. This made count impractical for many use cases. With for_each, Terraform will maintain a map of resources instead of a list, with a unique identity for each resource, so if you delete something in the middle, it only affects that one item!

What to do about it: We’ve updated the Terraform tips & tricks: loops, if-statements, and gotchas blog post to Terraform 0.12.6 syntax, including lots of examples of how to use for_each with resources. Check out the blog post, upgrade your code to 0.12.6, and enjoy a more powerful Terraform experience!

Amazon Aurora Multi-Master is now Generally Available

What happened: Amazon has announced that Amazon Aurora Multi-Master is now available to all customers.

Why it matters: Amazon Aurora Multi-Master allows you to create multiple read-write instances of your Aurora database across multiple Availability Zones, so even if one instance or Availability Zone fails, you can continue accepting writes without downtime or failover.

What to do about it: Check out the announcement blog post for details.

Amazon ECS services now support multiple load balancer target groups

What happened: Amazon ECS now supports attaching multiple target groups to each ECS Service.

Why it matters: Previously, you could attach only one target group to an ECS service. This meant you had to create multiple copies of the service for use cases such as serving traffic from internal and external facing load balancers or exposing multiple ports. Now, you can attach multiple target groups per ECS service, handling all of these use cases with just a single copy of your service.

What to do about it: Check out the documentation for details. Please note that we have not yet updated module-ecs to support this functionality. We will send out an update once we’ve had a chance to prioritize this work (in the meantime, PRs are very welcome!).

Amazon ECR now supports increased repository and image limits

What happened: Amazon ECR now supports 10,000 repositories per region and 10,000 images per repository by default.

Why it matters: Previously, the default limit was 1,000 repositories per region and 1,000 images per repository, so it was common to hit that limit if you push images frequently (e.g., after every commit). The default limit is now significantly higher, and you can request it further by request.

What to do about it: See the announcement blog post for details.

Security Updates

Below is a list of critical security updates that may impact your services. We notify Gruntwork customers of these vulnerabilities as soon as we know of them via the Gruntwork Security Alerts mailing list. It is up to you to scan this list and decide which of these apply and what to do about them, but most of these are severe vulnerabilities, and we recommend patching them ASAP.

Mozilla Firefox

Text Link