7
7
[ ![ ] ( https://img.shields.io/badge/github-cytopia%2Fdocker--terragrunt-red.svg )] ( https://github.com/cytopia/docker-terragrunt " github.com/cytopia/docker-terragrunt ")
8
8
[ ![ License] ( https://img.shields.io/badge/license-MIT-%233DA639.svg )] ( https://opensource.org/licenses/MIT )
9
9
10
- > #### All awesome CI Docker images
10
+ > #### All [ # awesome-ci ] ( https://github.com/topics/awesome-ci ) Docker images
11
11
>
12
12
> [ ansible] ( https://github.com/cytopia/docker-ansible ) |
13
13
> [ ansible-lint] ( https://github.com/cytopia/docker-ansible-lint ) |
@@ -25,8 +25,8 @@ View **[Dockerfile](https://github.com/cytopia/docker-terragrunt/blob/master/Doc
25
25
26
26
[ ![ Docker hub] ( http://dockeri.co/image/cytopia/terragrunt )] ( https://hub.docker.com/r/cytopia/terragrunt )
27
27
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 >.
30
30
31
31
* <sub >[ 1] Official project: https://github.com/gruntwork-io/terragrunt </sub >
32
32
* <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.
61
61
62
62
## Docker mounts
63
63
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.)
65
66
66
67
67
68
## Usage
@@ -72,22 +73,75 @@ docker run --rm -v $(pwd):/data cytopia/terragrunt terragrunt <ARGS>
72
73
docker run --rm -v $( pwd) :/data cytopia/terragrunt terraform < ARGS>
73
74
```
74
75
75
- ### Provision single sub-project on AWS
76
+ ### Simple: Provision single sub-project on AWS
76
77
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
77
129
```
130
+
131
+ ### Complex: Provision single sub-project on AWS
132
+ Let's assume your Terragrunt project setup is as follows:
133
+ ``` bash
78
134
/my/tf # Terragrunt project root
79
135
└── envs
80
136
└── aws
81
137
├── dev
82
138
│ ├── eu-central-1
83
139
│ │ ├── infra
84
140
│ │ │ └── vpc-k8s # VPC sub-project directory
85
- │ │ │ ├── include_providers.tf
86
141
│ │ │ ├── terraform.tfvars
87
142
│ │ │ └── terragrunt.hcl
88
143
│ │ ├── microservices
89
144
│ │ │ └── api-gateway
90
- │ │ │ ├── include_providers.tf
91
145
│ │ │ ├── terraform.tfvars
92
146
│ │ │ └── terragrunt.hcl
93
147
│ │ └── region.tfvars
@@ -97,7 +151,7 @@ Let's assume your Terragrunt project setup is as follows:
97
151
└── _provider_include
98
152
└── include_providers.tf
99
153
```
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/ ` .
101
155
102
156
1 . Mount the terragrunt root project dir (` /my/tf/ ` ) into ` /data/ ` into the container
103
157
2 . Use the workding dir (` -w ` or ` --workdir ` ) to point to your project inside the container
@@ -109,27 +163,27 @@ docker run --rm \
109
163
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
110
164
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
111
165
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
112
- -v /my/tf:/data cytopia/terragrunt \
166
+ -v /my/tf:/data \
113
167
-w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \
114
- terragrunt init
168
+ cytopia/terragrunt terragrunt init
115
169
116
170
# Plan the VPC project
117
171
docker run --rm \
118
172
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
119
173
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
120
174
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
121
- -v /my/tf:/data cytopia/terragrunt \
175
+ -v /my/tf:/data \
122
176
-w /data/envs/aws/dev/eu-central-1/infra/vpc-k8s \
123
- terragrunt plan
177
+ cytopia/terragrunt terragrunt plan
124
178
125
- # Apply the VPC project
179
+ # Apply the MySQL project
126
180
docker run --rm \
127
181
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
128
182
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
129
183
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
130
- -v /my/tf:/data cytopia/terragrunt \
184
+ -v /my/tf:/data \
131
185
-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
133
187
```
134
188
135
189
0 commit comments