From 7b3887c58994c11fdeef94a9d71f3915eef1069d Mon Sep 17 00:00:00 2001 From: cytopia Date: Thu, 20 Jun 2019 16:04:02 +0200 Subject: [PATCH] Initial commit --- README.md | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..87d0f84 --- /dev/null +++ b/README.md @@ -0,0 +1,140 @@ +# Docker image for `terragrunt` + +[![Build Status](https://travis-ci.com/cytopia/docker-terragrunt.svg?branch=master)](https://travis-ci.com/cytopia/docker-terragrunt) +[![Tag](https://img.shields.io/github/tag/cytopia/docker-terragrunt.svg)](https://github.com/cytopia/docker-terragrunt/releases) +[![](https://images.microbadger.com/badges/version/cytopia/terragrunt:latest.svg)](https://microbadger.com/images/cytopia/terragrunt:latest "terragrunt") +[![](https://images.microbadger.com/badges/image/cytopia/terragrunt:latest.svg)](https://microbadger.com/images/cytopia/terragrunt:latest "terragrunt") +[![](https://img.shields.io/badge/github-cytopia%2Fdocker--terragrunt-red.svg)](https://github.com/cytopia/docker-terragrunt "github.com/cytopia/docker-terragrunt") +[![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) + +> #### All awesome CI Docker images +> +> [ansible](https://github.com/cytopia/docker-ansible) | +> [ansible-lint](https://github.com/cytopia/docker-ansible-lint) | +> [awesome-ci](https://github.com/cytopia/awesome-ci) | +> [eslint](https://github.com/cytopia/docker-eslint) | +> [file-lint](https://github.com/cytopia/docker-file-lint) | +> [jsonlint](https://github.com/cytopia/docker-jsonlint) | +> [pycodestyle](https://github.com/cytopia/docker-pycodestyle) | +> [terraform-docs](https://github.com/cytopia/docker-terraform-docs) | +> [terragrunt](https://github.com/cytopia/docker-terragrunt) | +> [yamllint](https://github.com/cytopia/docker-yamllint) + + +View **[Dockerfile](https://github.com/cytopia/docker-terragrunt/blob/master/Dockerfile)** on GitHub. + +[![Docker hub](http://dockeri.co/image/cytopia/terragrunt)](https://hub.docker.com/r/cytopia/terragrunt) + +Tiny Alpine-based multistage-build dockerized version of [terragrunt](https://github.com/gruntwork-io/terragrunt)[1] +and its corresponding version of [terraform](https://github.com/hashicorp/terraform)[2]. + +* [1] Official project: https://github.com/gruntwork-io/terragrunt +* [2] Official project: https://github.com/hashicorp/terraform + + +## Available Docker image versions + +### Rolling releases +The following Docker image tags are rolling releases and built and updated nightly. This means +they always contain the latest stable version as shown below. + +| Docker tag | Terraform version | Terragrunt version | +|------------|-------------------|--------------------| +| `latest` | latest stable | latest stable | +| `012-019` | latest `0.12.x` | latest `0.19.x` | +| `011-018` | latest `0.11.x` | latest `0.18.x` | + + +### Point in time releases +If you want to ensure to have reproducible Terraform/Terragrunt executions you should use a git tag from +this repository. Tags are incremented for each new version, but never updated itself. This means +you will have to take care yourself and update your CI tools every time a new tag is being released. + +| Docker tag | docker-terragrunt | Terraform version | Terragrunt version | +|-----------------|-------------------|-----------------------------------|-----------------------------------| +| `latest-` | Tag: `` | latest stable during tag creation | latest stable during tag creation | +| `012-019-` | Tag: `` | latest 0.12.x during tag creation | latest stable during tag creation | +| `011-018-` | Tag: `` | latest 0.11.x during tag creation | latest stable during tag creation | + +Where `` refers to the chosen git tag from this repository. + + +## Docker mounts + +The working directory inside the Docker container is `/data/` and should be mounted to your local filesystem. + + +## Usage + +### Generic +```bash +docker run --rm -v $(pwd):/data cytopia/terragrunt terragrunt +docker run --rm -v $(pwd):/data cytopia/terragrunt terraform +``` + +### Provision single sub-project on AWS +Let's assume your Terragrunt project setup is as follows: +``` +. # <-- Terragrunt project root +└── envs +    └── aws +    ├── dev +    │   ├── eu-central-1 +    │   │   ├── infra +    │   │   │   └── vpc-k8s # <-- VPC sub-project directory +    │   │   │   ├── include_providers.tf +    │   │   │   ├── terraform.tfvars +    │   │   │   └── terragrunt.hcl +    │   │   ├── microservices +    │   │   │   └── api-gateway +    │   │   │   ├── include_providers.tf +    │   │   │   ├── terraform.tfvars +    │   │   │   └── terragrunt.hcl +    │   │   └── region.tfvars +    │   ├── global +    │   │   └── region.tfvars +    │   └── terragrunt.hcl +    └── _provider_include +    └── include_providers.tf +``` +The VPC sub-project you want to provision is at the path `envs/aws/dev/eu-centra-1/infra/vpc-k8s/`. + +1. Mount the terragrunt root project dir into `/data/` into the container +2. Use the workding dir (`-w` or `--workdir`) to point to your project inside the container +3. Add AWS credentials from your environment + +```bash +# Initialize the VPC project +docker run --rm \ + -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ + -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ + -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \ + -v $(pwd):/data cytopia/terragrunt \ + -w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \ + terragrunt init + +# Plan the VPC project +docker run --rm \ + -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ + -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ + -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \ + -v $(pwd):/data cytopia/terragrunt \ + -w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \ + terragrunt plan + +# Apply the VPC project +docker run --rm \ + -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ + -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ + -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \ + -v $(pwd):/data cytopia/terragrunt \ + -w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \ + terragrunt --terragrunt-non-interactive apply +``` + + +## License + +**[MIT License](LICENSE)** + +Copyright (c) 2019 [cytopia](https://github.com/cytopia)