Skip to content
A repo used to show examples file/folder structures you can use with Terragrunt and Terraform
Branch: master
Clone or download
brikis98 Merge pull request #7 from gruntwork-io/tf12
Update to Terraform 0.12.x and Terragrunt v0.19.0
Latest commit 9e6b210 Jun 10, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
asg-elb-service Update to Terraform 0.12 and Terragrunt 0.19.0 Jun 10, 2019
mysql Update to Terraform 0.12 and Terragrunt 0.19.0 Jun 10, 2019
.gitignore Initial commit Jul 2, 2017

Maintained by

Example infrastructure-modules for Terragrunt

This repo, along with the terragrunt-infrastructure-live-example repo, show an example file/folder structure you can use with Terragrunt to keep your Terraform code DRY. For background information, check out the Keep your Terraform code DRY section of the Terragrunt documentation.

This repo contains the following example code:

  • asg-elb-service: An example of how to deploy an Auto Scaling Group (ASG) with an Elastic Load Balancer (ELB) in front of it. We run a dirt-simple "web server" on top of the ASG that always returns "Hello, World".

  • mysql: An example of how to deploy MySQL on top of Amazon's Relational Database Service (RDS).

Note: This code is solely for demonstration purposes. This is not production-ready code, so use at your own risk. If you are interested in battle-tested, production-ready Terraform code, check out Gruntwork.

How do you use these modules?

To use a module, create a terragrunt.hcl file that specifies the module you want to use as well as values for the input variables of that module:

# Use Terragrunt to download the module code
terraform {
  source = ""

# Fill in the variables for that module
inputs = {
  foo = "bar"
  baz = 3

(Note: the double slash (//) in the source URL is intentional and required. It's part of Terraform's Git syntax for module sources.)

You then run Terragrunt, and it will download the source code specified in the source URL into a temporary folder, copy your terragrunt.hcl file into that folder, and run your Terraform command in that folder:

> terragrunt apply
[terragrunt] Reading Terragrunt config file at terragrunt.hcl
[terragrunt] Downloading Terraform configurations from
[terragrunt] Copying files from . into .terragrunt-cache
[terragrunt] Running command: terraform apply

Check out the terragrunt-infrastructure-live-example repo for examples and the Keep your Terraform code DRY documentation for more info.

How do you change a module?

Local changes

Here is how to test out changes to a module locally:

  1. git clone this repo.
  2. Update the code as necessary.
  3. Go into the folder where you have the terragrunt.hcl file that uses a module from this repo (preferably for a dev or staging environment!).
  4. Run terragrunt plan --terragrunt-source <LOCAL_PATH>, where LOCAL_PATH is the path to your local checkout of the module code.
  5. If the plan looks good, run terragrunt apply --terragrunt-source <LOCAL_PATH>.

Using the --terragrunt-source parameter (or TERRAGRUNT_SOURCE environment variable) allows you to do rapid, iterative, make-a-change-and-rerun development.

Releasing a new version

When you're done testing the changes locally, here is how you release a new version:

  1. Update the code as necessary.

  2. Commit your changes to Git: git commit -m "commit message".

  3. Add a new Git tag using one of the following options:

    1. Using GitHub: Go to the releases page and click "Draft a new release".
    2. Using Git:
    git tag -a v0.0.2 -m "tag message"
    git push --follow-tags
  4. Now you can use the new Git tag (e.g. v0.0.2) in the ref attribute of the source URL in terragrunt.hcl.

  5. Run terragrunt plan.

  6. If the plan looks good, run terragrunt apply.

You can’t perform that action at this time.