• Stars
    star
    371
  • Rank 115,103 (Top 3 %)
  • Language HCL
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terragrunt Reference Architecture (upd: May 2020)

Acme's Infrastructure - Terragrunt Reference Architecture (updated: May 2020)

This repository contains rather complete infrastructure configurations where Terragrunt is used to manage infrastructure for Acme Corporation.

By the way!

This code is very close to the one produced by modules.tf - open-source infrastructure as code generator from visual diagrams created with Cloudcraft.co. See it yourself in modules.tf-demo!

Introduction

Acme has several environments (prod, staging and dev) entirely separated by AWS accounts.

Infrastructure in each environment consists of multiple layers (autoscaling, alb, vpc, ...) where each layer is configured using one of Terraform AWS modules with arguments specified in terragrunt.hcl in layer's directory.

Terragrunt is used to work with Terraform configurations which allows orchestrating of dependent layers, update arguments dynamically and keep configurations DRY.

Environments

Primary AWS region for all environments is eu-central-1 (Frankfurt):

  • acme-prod - Production configurations (AWS account - 111111111111)

  • acme-staging - Staging configurations (AWS account - 444444444444)

  • acme-master - Master AWS account (333333333333) contains:

    • AWS Organizations
    • IAM entities (users, groups)
    • ECR repositories
    • Route53 zones

Pre-requirements

If you are using macOS you can install all dependencies using Homebrew:

$ brew install terraform terragrunt pre-commit

Configure access to AWS account

Acme has dedicated AWS account where IAM users, groups and roles managed. This AWS account is a jump account, where IAM users logged in, and then they assume role in other AWS account.

The recommended way to configure access credentials to AWS account is using environment variables:

$ export AWS_DEFAULT_REGION=eu-west-1
$ export AWS_ACCESS_KEY_ID=...
$ export AWS_SECRET_ACCESS_KEY=...

Alternatively, you can edit terragrunt.hcl and use another authentication mechanism as described in AWS provider documentation.

aws-vault, vaulted, awsp or other tool can be used to manage your AWS credentials securely locally and switch roles.

Create and manage your infrastructure

Infrastructure consists of multiple layers (vpc, alb, ...) where each layer is described using one Terraform module with inputs arguments specified in terragrunt.hcl in respective layer's directory.

Navigate through layers to review and customize values inside inputs block.

There are two ways to manage infrastructure (slower&complete, or faster&granular):

  • Region as a whole (slower&complete). Run this command to create infrastructure in all layers in a single region:
$ cd acme-prod/eu-central-1
$ terragrunt apply-all
  • As a single layer (faster&granular). Run this command to create infrastructure in a single layer (eg, vpc):
$ cd acme-prod/eu-central-1/vpc
$ terragrunt apply

After you confirm the creation of the infrastructure should succeed.

If you want to suppress irrelevant output produced by Terragrunt, you can install this alias in your shell (source to gist):

terragrunt () {
	local action=$1
	shift 1
	command terragrunt $action "$@" 2>&1 | sed -E "s|$(dirname $(pwd))/||g;s|^\[terragrunt\]( [0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})* ||g;s|(\[.*\]) [0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}|\1|g"
}

References

Author

This project is created and maintained by Anton Babenko.

Maintained by Anton Babenko @antonbabenko

License

All content, including Terraform AWS modules used in these configurations, is released under the MIT License.

Copyright (c) 2019-2020 Anton Babenko

More Repositories

1

pre-commit-terraform

pre-commit git hooks to take care of Terraform configurations 🇺🇦
Shell
3,145
star
2

terraform-best-practices

Terraform Best Practices free ebook translated into 🇬🇧🇦🇪🇧🇦🇧🇷🇫🇷🇬🇪🇩🇪🇬🇷🇮🇱🇮🇳🇮🇩🇮🇹🇰🇷🇵🇱🇷🇴🇨🇳🇪🇸🇹🇷🇺🇦🇵🇰
HCL
1,991
star
3

serverless.tf

serverless.tf is an opinionated open-source framework for developing, building, deploying, and securing serverless applications and infrastructures on AWS using Terraform.
726
star
4

terraform-cost-estimation

Anonymized, secure, and free Terraform cost estimation based on Terraform plan (0.12+) or Terraform state (any version)
jq
679
star
5

terraform-aws-devops

Info about many of my Terraform, AWS, and DevOps projects.
422
star
6

modules.tf-lambda

Infrastructure as code generator - from visual diagrams created with Cloudcraft.co to Terraform
Python
349
star
7

terraform-best-practices-workshop

Terraform Best Practices - workshop materials
HCL
237
star
8

terraform-docs-as-pdf

Complete Terraform documentation (core + all official providers) as PDF files. Updating nightly.
Shell
201
star
9

awsp

AWS credential profile changer
Shell
91
star
10

you-have-passed-the-certification

I'm glad you have passed the certification! I just don't want to see posts about it in my LinkedIn newsfeed.
JavaScript
77
star
11

terrapin

[not-WIP] Terraform module generator (not ready for its prime time, yet)
Shell
71
star
12

modules.tf-demo

Real modules.tf demo (updated May 2021)
HCL
41
star
13

serverless.tf-playground

serverless.tf playground for examples and experiments
HCL
38
star
14

terraform-deployment-pipeline-talk

Code for my talks about Terraform in deployment pipeline
HCL
33
star
15

terraform-provider-openai

Terraform provider for OpenAI (experimental as hell)
Go
26
star
16

terraform-aws-anything

Content for "Manage any AWS resource with Terraform"
HCL
24
star
17

tfvars-annotations

[not-WIP] Update values in terraform.tfvars using annotations
Go
23
star
18

terrible

[not-WIP] Let's orchestrate Terraform configuration files with Ansible! Terrible!
Makefile
23
star
19

antonbabenko

12
star
20

addo-demo

All code used during my All Day DevOps talk
HCL
7
star
21

terramate-reference-architecture

WIP: Terramate Reference Architecture
HCL
7
star
22

renovatebot-tf-tg-demo

Renovatebot with Terraform and Terragrunt
HCL
5
star
23

.github

Meta repository for all repositories in my account
1
star