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.
In the last couple months, we’ve released a guide to using Gruntwork with Terraform Cloud and Terraform Enterprise, created a new module for Amazon’s Elastic File Store (EFS), added PrivateLink support to keep AWS API calls within your VPC network, added support for managing secrets in Terragrunt using Mozilla SOPS, did a podcast interview with SE Radio, and made a huge number of other fixes and improvements.
As always, if you have any questions or need help, email us at support@gruntwork.io!
Motivation:**** Gruntwork customers love saving time by using the Gruntwork IaC Library to do the heavy lifting of building production-grade cloud infrastructure. Many in the Terraform community have enjoyed using Terragrunt for its ability to keep your code and variables, CLI args, etc DRY, and for better support when applying changes across multiple accounts/modules/environments. HashiCorp customers love using Terraform Cloud (TFC) and/or Terraform Enterprise (TFE) for its browser-based controls, support for teams, and remote execution features. Fortunately, in this case, you can have your cake, and eat it too! Gruntwork and Terragrunt are compatible with Terraform Cloud and Terraform Enterprise.
Solution: We’ve written a blog post that shows you how to use Gruntwork’s Terrraform modules with TFC/TFE and even how to integrate Terragrunt with TFC/TFE. We’ve also updated our guide, How to Use the Gruntwork Infrastructure as Code Library, with all the details you need to set the integration up for yourself. Take a look and let us know what you think!
Motivation: Amazon’s Elastic File System (EFS) gives you a managed, scalable, elastic NFS file system in the cloud. It’s an easy way to create a hard-disk that’s shared across many EC2 instances, but we did not have any module to deploy and manage EFS as code.
Solution: We’ve added a new efs
module to module-data-storage
! This makes it easy to use EFS in just a few lines of code:
module "efs" {
source = "git::git@github.com:gruntwork-io/module-data-storage.git//modules/efs?ref=v0.12.15"
name = "example-efs"
vpc_id = data.aws_vpc.default.id
subnet_ids = data.aws_subnet_ids.default.ids
}
A huge thank you to Jesse Bye for contributing this new module!
What to do about it: Try out the new efs
module and let us know what you think!
Motivation: By default, any API calls you make to AWS go over the public Internet, even if you make those API calls from within a VPC in your AWS account. You can keep those API calls more private by routing them entirely within your VPC using VPC Endpoints (which are built into the Gruntwork VPC modules), but VPC Endpoints only support S3 and DynamoDB. For all other AWS services, you need to use PrivateLink, a separate (paid) service, which our VPC module did not support.
Solution: We’ve added a new vpc-interface-endpoint
module to module-vpc
which you can use to enable PrivateLink for AWS services in your VPC. Here’s an example of how to use the module to enable PrivateLink for all calls to AWS EC2 APIs:
module "vpc" {
source = "git::git@github.com:gruntwork-io/module-vpc.git//modules/vpc-app?ref=v0.8.7"
vpc_name = "example-vpc"
aws_region = "us-east-1"
cidr_block = "10.0.0.0/16"
}
module "vpc_endpoint_ec2_example" {
source = "git::git@github.com:gruntwork-io/module-vpc.git//modules/vpc-interface-endpoint?ref=v0.8.7"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_app_subnet_ids
# Enable PrivateLink for EC2
enable_ec2_endpoint = true
}
Note that using PrivateLink incurs an extra fee per hour per AZ where PrivateLink is deployed and per GB of data processed, so make sure to check the pricing page before enabling it for all services!
What to do about it: If you want an extra layer of privacy for your AWS API calls, try out the new vpc-interface-endpoint
module and let us know what you think!
Motivation: Terraform does not have great native features for managing secrets (see this issue, which has been open for ~6 years).
Solution: We’ve added support for Mozilla SOPS to Terragrunt. SOPS allows you to securely store secrets in JSON or YAML files encrypted via AWS KMS, GCP KMS, Azure Key Vault, or PGP. For example, you might have a secrets.yml
with the contents:
db:
user: ENC[AES256_GCM,data:CwE4O1s=,iv:2k=,aad:o=,tag:w==]
password: ENC[AES256_GCM,data:p673w==,iv:YY=,aad:UQ=,tag:A=]
Note that the user
and password
are encrypted with one of the mechanisms supported by SOPS, which means it is safe to check this file into version control. You use the new sops_decrypt_file
helper in your terragrunt.hcl
files to automatically read the file and decrypt the contents, allowing you to pass those values to your Terraform code:
locals {
secrets = yamldecode(sops_decrypt_file("secrets.yml"))
}
inputs = {
user = local.secrets.db.user
password = local.secrets.db.password
}
This approach allows you to avoid putting any plain text secrets directly in version control, while still managing everything as code. Note that any secrets you pass to Terraform may be stored in its state file in plain text, so make sure you store that state file in an encrypted format too (e.g., using S3 encryption)!
What to do about it: Check out the sops_decrypt_file
documentation, give the new helper a try, and let us know what you think!
Motivation: The team at Software Engineering (SE) Radio wanted to know more about infrastructure as code.
Solution: Gruntwork co-founder Yevgeniy (Jim) Brikman did a podcast interview with SE Radio on Infrastructure as Code Best Practices. The discussion covers similarities and differences between conventional software engineering and code-driven infrastructure; factoring code into modules; layering; terraform code organization for micro-services; releases and tagging; code reviews; unit testing infrastructure; deployment of infrastructure; ownership and code structure models; and open source and re-usable libraries.
What to do about it: Listen to the Infrastructure as Code Best Practices Podcast and leave your thoughts in the comments.
hclfmt
now supports formatting a single file as opposed to an entire directory tree. Use --terragrunt-hclfmt-file
to specify the single file you wish to format.v0.12.24
). Previously unavailable functions such as trim
, try
, and can
are now available. hclfmt
has also been upgraded to handle formatting files with heredoc syntax correctly.--help
text for Terragrunt.graph-dependencies
which can be used to get a graph representation of the dependency relations between all the modules.read_terragrunt_config
were broken when used in a module that was pulled in with dependency
blocks.--terragrunt-source
on a module with dependencies updated the source of both the current module and the dependency. Starting this version, when using --terragrunt-source
on a module with a dependency the dependency's terraform source will be updated to the combined path using //
as an anchor.generate
blocks now support an optional attribute disable_signature
, which, when true
, will avoid emitting the signature line at the top of the generated file.-var
and -var-file
arguments when you run destroy
with a plan file.TooManyUpdates error for SSM param
.get_env
can now be made to force an environment variable to be defined. When used with a single argument, the function will error if the environment variable returns empty string. This release also introduces a new helper function, get_terraform_command
which can be used to see what the current executed command by terragrunt
is.remote_state
block will now properly handle new accounts that do not have the default s3 KMS key created.get_terraform_cli_args
) to introspect terraform args in your terragrunt config. This can be used to conditionally adjust your hooks based on what args are passed in (e.g. plan --destroy
vs. plan
).--terragrunt-parallelism
CLI argument that you can use to limit parallelism when executing xxx-all
commands (e.g. ,apply-all
). This is useful if, for example, you are running apply-all
on a large number of modules, and starting to hit cloud provider rate limits as a result.--help
text of Terragrunt.sops_decrypt_file
, which will decrypt an encrypted file using SOPS.IsPodAvailable
was not accounting for readiness of the containers. This could lead to returning true
when the pod was not ready for accepting connections. This release updates the function to only return true
if all the containers in the Pod are ready.EmptyS3Bucket
/ EmptyS3BucketE
functions now also clean up delete markers.IsMinikubeE
is now more robust to different flavors of Minikube.OutputMaxLineSize
to all terraform calls.docker.Inspect
and docker.InspectE
methods to run docker inspect
and return the results in a convenient struct
. Added docker.RunAndGetID
and docker.RunAndGetIDE
methods to run docker run
and return the ID of the started container.terratest_log_parser
now buffers input lines so that it can support parsing long lines.OutputMaxLineSize
to respective command options when you have long outputs. As such the option has been removed from the respective structs.ContainerInspect
struct returned by docker.Inspect
now includes health check data.helm.RenderTemplate
and helm.RenderTemplateE
functions.Logf(t testing.TestingT, format string, args ...interface{})
can be used for logging by wrapping it in the Logger
type using logger.New
. See the provided loggers in the logging
package for more info.cloud-nuke
now supports nuking S3 buckets. Note that you can exclude certain buckets from consideration by tagging them with the tag key cloud-nuke-excluded
and value true
. This release also introduces a new CLI arg --exclude-resource-type
for removing certain resource types from consideration. For example, to avoid nuking s3 buckets entirely, you can pass in cloud-nuke aws --exclude-resource-type s3
. Use cloud-nuke aws --list-resource-types
to see all the supported resource types.--log-level
param.Also, cloud-nuke
now fetches S3 bucket info concurrently, which should speed the process up by 5-10x.kubergrunt
gke-cluster
module called services_secondary_range_name
that allows you to specify the name of the secondary range within the subnetwork for the services to use.enable_flow_logs
parameter from the vpc-network
module in favor of the new log_config
parameter.systemd
instead of supervisord
, as systemd
is now available on all major Linux distros.nomad-consul.json
to use clean_resource_name
instead of clean_ami_name
, as the latter was deprecated in Packer 1.5+.nomad-consul.json
to configure Docker to start at boot.nomad-cluster
module will now respect a snapshot_id
setting passed in via the ebs_block_devices
input variable.--progress
flag to have fetch
show progress during downloads. This is especially useful for large downloads.v0.3.6
. This means that you can now pass empty values again to --branch
, --tag
, and --commit
, as long as one of those is non-empty, and fetch
will handle it correctly.local readonly
to local -r
, which is the proper way to declare local, read-only variables in Bash.gruntwork-install
parses, passes around, and logs --module-param
arguments to ensure whitespace is handled correctly.executable-dependency
that can be used to install an executable if it's not installed already. This is useful if your Terraform code depends on external dependencies, such as terraform-aws-eks
, which depends on kubergrunt
.enabled-aws-regions
has been removed as there is now a new data source in the aws
provider that has the same functionality. Replace usage of the module with the aws_regions
data source
parameter_group_name_for_read_replicas
input variable to set a separate parameter group for read replicas and allow_connections_from_security_groups_to_read_replicas
and allow_connections_from_cidr_blocks_to_read_replicas
to configure a separate security group for read replicas.cluster_iam_roles
input variable.eks-cluster-workers
now supports the create_resources
parameter, which when false
, will turn off all the resources in the module.fargate_only
flag on eks-cluster-control-plane
module and replaces it with the more descriptive and accurate schedule_control_plane_services_on_fargate
. Refer to the release notes for more details.schedule_control_plane_services_on_fargate = true
, you will now need to use kubergrunt
version 0.5.12
or greater.eks-k8s-cluster-autoscaler-iam-policy
are now computed in a manner that is more robust to loss of credentials during an apply
.coredns
containers get updated to the latest version. In the newer versions of coredns
, the configuration has a backwards incompatible change that was previously unhandled in the upgrade scripts. This release fixes that issue such that it will reformat the configuration to match expectations of later coredns
versions.eks-cluster-workers
to use properly use var.custom_tags_security_group
to allow custom tags for SG.eks-cluster-managed-workers
by setting create_resources = false
. This allows you to implement conditional logic to turn on or off a module block in your terraform module.eks-cluster-control-plane
module will now automatically download and install kubergrunt
if it is not available in the target system. This behavior can be disabled by setting the input variable auto_install_kubergrunt
to false
.access_logs_bucket_suffix
.redis
using the new kms_key_id
input variable.lambda-edge
.lambda
, lambda-edge
, and scheduled-lambda-job
modules.lambda
and lambda-edge
now support setting reserved_concurrent_executions
on the underlying Lambda function.lambda
module is now more robust to partial failures in the module. Previously you could end up in a state where you couldn't apply
or destroy
the module if it only partially applied the resources due to output errors. This release addresses that by changing the output logic.kms-master-key-multi-region
, which can be used to manage KMS CMKs across all enabled regions of an account.num_days_after_which_delete_log_data = 0
no longer works and leads to a provider schema error. This meant that there was no way to configure S3 buckets to never delete data. Starting with this release, you can now prevent deletion of data in S3 for aws-config
and cloudtrail
by setting the respective variables to null
.customer_master_keys
variable of the kms-master-key
module are now optional instead of required. The module will now only add IAM policy statements for the parameters that are actually set.cmk_service_principals
parameter and specifying the actions those Service Principals will be allowed to do via a new service_principal_actions
input variable.kms-master-key
so that the optional released in v0.28.3 works properly.ssh-grunt
has changed such that IAM users will be sync’d even if there is a duplicate user name. Previously, ssh-grunt
would throw an error and stop processing other users.ssh-grunt
, cloudtrail
, kms-master-key
, and the *-multi-region
modules. See the release notes for details.account-baseline-app
and account-baseline-security
to allow for centralizing Config output in a single bucket. In this release, we take the same approach with account-baseline-root
. It now supports using config bucket in security account. Additionally, the iam-policies
module now allows sts:TagSession for the automation users.cloudtrail
module now supports reusing an existing KMS key in your account, as opposed to creating a new one. To use an existing key, set the kms_key_already_exists
variable to true
and provide the ARN of the key to the variable kms_key_arn
.rds_disk_space_available
alarm where it would be enabled, incorrectly, for Aurora instances.alb-alarms
module where for "low" thresholds (e.g., low request count) it was using GreaterThanThreshold
instead of LessThanThreshold
.cloudwatch-dashboard
module now supports managing multiple dashboards in one module.install.sh
scripts for the cloudwatch-log-aggregation-scripts
, syslog
, and cloudwatch-memory-disk-metrics-scripts
modules were unnecessarily using eval
to execute scripts used in the install steps. This led to unexpected behavior, such as --module-param
arguments being shell expanded. We've removed the calls to eval
and replaced with a straight call to the underlying scripts.openvpn-server
module which if the Elastic IP associated with the OpenVPN Server was deleted, Terraform would throw an invalid index error.Dockerfile
for infrastructure-deploy-script
now includes bitbucket.org in known_hosts
list. Also fix bug where v0.18.5
was incompatible with previous versions of infrastructure-deployer
.infrastructure-deployer
and infrastructure-deploy-script
has been renamed to --log-level
instead of --loglevel
. The infrastructure-deploy-script
no longer supports passing in the private SSH key via CLI args. You must pass it in with the environment variable DEPLOY_SCRIPT_SSH_PRIVATE_KEY
.install-jenkins
will automatically disable jenkins so that it won't start on boot. This ensures that jenkins will not be started unless it has been successfully configured with run-jenkins
.ecs-deploy-runner
now supports specifying multiple container images, and choosing a container image based on a user defined name. This allows you to configure and use different Docker containers for different purposes of your infrastructure pipeline.build-packer-artifact
now supports building a packer template from a git repository. See the updated docs for more info.single-server
module now applies the tags passed in via the tags
input variable to the EIP and IAM Role resources it creates.sns
module.aws-securityhub
no longer depends on python to get enabled regions, and instead uses a terraform native data source.platform_version
variable.server-group
module for the root block device by using the root_block_device_encrypted
input variable.What happened: EKS now supports Kubernetes 1.16 and Kubernetes 1.13 is now considered deprecated.
Why this matters: Kubernetes 1.16 includes support for volume resizing, Windows GMSA, and Finalizer Protection for Service LoadBalancers. Also, custom resource definitions and admission webhooks have both graduated to generally available. As for Kubernetes 1.13, since EKS only supports the 3 most recent releases, 1.13 is now officially deprecated in EKS and will no longer be supported by June 30, 2020, so if you’re still using it, make sure to update ASAP!
What to do about it: We are updating terraform-aws-eks
with support for 1.16 as we speak: follow PR #160 for details. Once that PR is merged, you are safe to upgrade. If you’re still on 1.13, you should update ASAP!
What happened:**** AWS has made two big improvements to its Elastic File System (EFS) Service: it now supports up to 35,000 read operations per second (a 400% increase) and ECS and Fargate tasks can now mount EFS file systems.
What to do about it: Check out the documentation for EFS limits and mounting EFS Volumes for details. Also, give our new efs
module announced earlier in the newsletter a try!
What happened: HashiCorp has released Vault 1.4.
Why it matters: Some of the highlights of Vault 1.4 include:
What to do about it: Try the new version out and let us know what you think!
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.
locals
argument of a render
call. This vulnerability has been assigned the CVE identifier CVE-2020–8163. We recommend that users of Rails < 5.0.1 upgrade to a version ≥= 5.0.1. More information: https://groups.google.com/forum/#!topic/rubyonrails-security/hWuKcHyoKh0