Skip to content

Commit 6bdb2e8

Browse files
committed
Clean up examples
1 parent 65c3a0e commit 6bdb2e8

File tree

1 file changed

+69
-15
lines changed

1 file changed

+69
-15
lines changed

‎README.md

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![](https://img.shields.io/badge/github-cytopia%2Fdocker--terragrunt-red.svg)](https://github.com/cytopia/docker-terragrunt "github.com/cytopia/docker-terragrunt")
88
[![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT)
99

10-
> #### All awesome CI Docker images
10+
> #### All [#awesome-ci](https://github.com/topics/awesome-ci) Docker images
1111
>
1212
> [ansible](https://github.com/cytopia/docker-ansible) |
1313
> [ansible-lint](https://github.com/cytopia/docker-ansible-lint) |
@@ -25,8 +25,8 @@ View **[Dockerfile](https://github.com/cytopia/docker-terragrunt/blob/master/Doc
2525

2626
[![Docker hub](http://dockeri.co/image/cytopia/terragrunt)](https://hub.docker.com/r/cytopia/terragrunt)
2727

28-
Tiny Alpine-based multistage-build dockerized version of [terragrunt](https://github.com/gruntwork-io/terragrunt)<sup>[1]</sup>
29-
and its corresponding version of [terraform](https://github.com/hashicorp/terraform)<sup>[2]</sup>.
28+
Tiny Alpine-based multistage-build dockerized version of [Terragrunt](https://github.com/gruntwork-io/terragrunt)<sup>[1]</sup>
29+
and its comptaible version of [Terraform](https://github.com/hashicorp/terraform)<sup>[2]</sup>.
3030

3131
* <sub>[1] Official project: https://github.com/gruntwork-io/terragrunt</sub>
3232
* <sub>[2] Official project: https://github.com/hashicorp/terraform</sub>
@@ -61,7 +61,8 @@ Where `<tag>` refers to the chosen git tag from this repository.
6161

6262
## Docker mounts
6363

64-
The working directory inside the Docker container is **`/data/`** and should be mounted to your local filesystem.
64+
The working directory inside the Docker container is **`/data/`** and should be mounted to your local filesystem where your Terragrant project resides.
65+
(See [Usage](#usage) for in-depth examples of mount locations.)
6566

6667

6768
## Usage
@@ -72,22 +73,75 @@ docker run --rm -v $(pwd):/data cytopia/terragrunt terragrunt <ARGS>
7273
docker run --rm -v $(pwd):/data cytopia/terragrunt terraform <ARGS>
7374
```
7475

75-
### Provision single sub-project on AWS
76+
### Simple: Provision single sub-project on AWS
7677
Let's assume your Terragrunt project setup is as follows:
78+
```bash
79+
/my/tf # Terragrunt project root
80+
├── backend-app
81+
│ ├── main.tf
82+
│ └── terragrunt.hcl
83+
├── frontend-app
84+
│ ├── main.tf
85+
│ └── terragrunt.hcl
86+
├── mysql # MySQL sub-project directory
87+
│ ├── main.tf
88+
│ └── terragrunt.hcl
89+
├── redis
90+
│ ├── main.tf
91+
│ └── terragrunt.hcl
92+
└── vpc
93+
├── main.tf
94+
└── terragrunt.hcl
95+
```
96+
The MySQL sub-project you want to provision is at the releative path `mysql/`.
97+
98+
1. Mount the terragrunt root project dir (`/my/tf/`) into `/data/` into the container
99+
2. Use the workding dir (`-w` or `--workdir`) to point to your project inside the container
100+
3. Add AWS credentials from your environment to the container
101+
102+
```bash
103+
# Initialize the MySQL project
104+
docker run --rm \
105+
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
106+
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
107+
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
108+
-v /my/tf:/data \
109+
-w /data/mysql \
110+
cytopia/terragrunt terragrunt init
111+
112+
# Plan the MySQL project
113+
docker run --rm \
114+
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
115+
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
116+
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
117+
-v /my/tf:/data \
118+
-w /data/mysql \
119+
cytopia/terragrunt terragrunt plan
120+
121+
# Apply the VPC project
122+
docker run --rm \
123+
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
124+
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
125+
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
126+
-v /my/tf:/data \
127+
-w /data/mysql \
128+
cytopia/terragrunt terragrunt --terragrunt-non-interactive apply
77129
```
130+
131+
### Complex: Provision single sub-project on AWS
132+
Let's assume your Terragrunt project setup is as follows:
133+
```bash
78134
/my/tf # Terragrunt project root
79135
└── envs
80136
   └── aws
81137
   ├── dev
82138
   │   ├── eu-central-1
83139
   │   │   ├── infra
84140
   │   │   │   └── vpc-k8s # VPC sub-project directory
85-
   │   │   │   ├── include_providers.tf
86141
   │   │   │   ├── terraform.tfvars
87142
   │   │   │   └── terragrunt.hcl
88143
   │   │   ├── microservices
89144
   │   │   │   └── api-gateway
90-
   │   │   │   ├── include_providers.tf
91145
   │   │   │   ├── terraform.tfvars
92146
   │   │   │   └── terragrunt.hcl
93147
   │   │   └── region.tfvars
@@ -97,7 +151,7 @@ Let's assume your Terragrunt project setup is as follows:
97151
   └── _provider_include
98152
   └── include_providers.tf
99153
```
100-
The VPC sub-project you want to provision is at the path `envs/aws/dev/eu-centra-1/infra/vpc-k8s/`.
154+
The VPC sub-project you want to provision is at the relative path `envs/aws/dev/eu-centra-1/infra/vpc-k8s/`.
101155

102156
1. Mount the terragrunt root project dir (`/my/tf/`) into `/data/` into the container
103157
2. Use the workding dir (`-w` or `--workdir`) to point to your project inside the container
@@ -109,27 +163,27 @@ docker run --rm \
109163
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
110164
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
111165
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
112-
-v /my/tf:/data cytopia/terragrunt \
166+
-v /my/tf:/data \
113167
-w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \
114-
terragrunt init
168+
cytopia/terragrunt terragrunt init
115169

116170
# Plan the VPC project
117171
docker run --rm \
118172
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
119173
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
120174
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
121-
-v /my/tf:/data cytopia/terragrunt \
175+
-v /my/tf:/data \
122176
-w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \
123-
terragrunt plan
177+
cytopia/terragrunt terragrunt plan
124178

125-
# Apply the VPC project
179+
# Apply the MySQL project
126180
docker run --rm \
127181
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
128182
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
129183
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
130-
-v /my/tf:/data cytopia/terragrunt \
184+
-v /my/tf:/data \
131185
-w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \
132-
terragrunt --terragrunt-non-interactive apply
186+
cytopia/terragrunt terragrunt --terragrunt-non-interactive apply
133187
```
134188

135189

0 commit comments

Comments
 (0)