Terragrunt
Terragrunt is a wrapper that provides tools for keeping your configurations DRY, working with multiple Terraform modules, and managing remote state.
Last updated
Was this helpful?
Terragrunt is a wrapper that provides tools for keeping your configurations DRY, working with multiple Terraform modules, and managing remote state.
Last updated
Was this helpful?
This walkthrough will guide you through using Terragrunt with CloudTruth enabling you to manage your multiple environments parameters and secretes from a centralized location.
You can also use CloudTruth to externally reference backend .
You know basic .
You have installed .
You have created a and installed the .
Terragrunt with allows you to keep your code while centralizing your configuration input values.
Rather than using hardcoded and scattered Terragrunt to define parameter values, we will inject inputs directly from a specified CloudTruth and .
This example deployed with Terragrunt HCL will create an AWS Instance in us-west-2 and an S3 bucket, utilizing CloudTruth to manage Terraform variable keys and values for a development, production, and staging environment.
You can follow along in your AWS account by cloning this .
git clone https://github.com/cloudtruth-demo/terragrunt-cloudtruth-deploy.git
The Terragrunt folder structure for this repo contains development
, production
, and staging
directories.
Example instance terragrunt.hcl
:
Set unique resource tags that get applied to the EC2 instance and s3 bucket for each environment.
Now your CloudTruth Terragrunt project is setup to centrally manage the TF_VAR
variables with unique values for resource tags across our multiple environments.
Change directory to terragrunt-cloudtruth-deploy/development/
.
From terragrunt-cloudtruth-deploy/development/
execute the following command which passes variables from the CloudTruth project Terragrunt
for the development
environment into terragrunt:
You have now deployed an instance in EC2 and an S3 bucket with a DRY Terragrunt configuration and CloudTruth! 🙌
You can view the outputs that display the parameter values from the CloudTruth Development environment by running terragrunt run-all output
.
You can change to the production or staging directories and pass the respective CloudTruth environment to deploy various settings across your different infrastructure!
Destroy the AWS resources by passing environment variables the same way we created them.
You can see the source code for the Terraform modules and Terragrunt Deploy in the following repos.
The instance
and s3
sub-folders contain a terragrunt.hcl
file that set the source
parameter to point at the specific modules in the repo. They also include
the parent terragrunt.hcl
which configures the AWS provider.
Create a CloudTruth called Terragrunt
.
Now add the parameters to the Terragrunt
project that are required by the we are calling in the terragrunt.hcl.
Terragrunt any TF_VAR_xxx
variables you’ve manually set in your environment and follows the same variable precedence as . Using CloudTruth Run
we will pass the CloudTruth configured TF_VAR_xxx
variables directly to the Terraform modules through Terragrunt for the specified environment.