Skip to content

Commit 33a23d6

Browse files
authored
Merge pull request #58 from maddevsio/feature/pinned-terragrunt-version
Feature/pinned terragrunt version
2 parents 8b0cc9d + a34c590 commit 33a23d6

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@ This diagram shows the namespaces used in the cluster and the services deployed
146146
## Useful tools
147147

148148
- [tfenv](https://github.com/tfutils/tfenv) - tool for managing different versions of terraform; the required version can be specified directly as an argument or via `.terraform-version`
149+
- [tgenv](https://github.com/cunymatthieu/tgenv) - tool for managing different versions of terragrunt; the required version can be specified directly as an argument or via `.terragrunt-version`
149150
- [terraform](https://www.terraform.io/) - terraform itself, our main development tool: `tfenv install`
150151
- [awscli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) - console utility to work with AWS API
151152
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) - conssole utility to work with Kubernetes API
152153
- [kubectx + kubens](https://github.com/ahmetb/kubectx) - power tools for kubectl help you switch between Kubernetes clusters and namespaces
153154
- [helm](https://helm.sh/docs/intro/install/) - tool to create application packages and deploy them into k8s
154155
- [helmfile](https://github.com/roboll/helmfile) - "docker compose" for helm
155-
- [terragrunt](https://terragrunt.gruntwork.io/) - small terraform wrapper providing DRY approach in some cases
156+
- [terragrunt](https://terragrunt.gruntwork.io/) - small terraform wrapper providing DRY approach in some cases: `tgenv install`
156157
- [awsudo](https://github.com/meltwater/awsudo) - simple console utility that allows running awscli commands assuming specific roles
157158
- [aws-vault](https://github.com/99designs/aws-vault) - tool for securely managing AWS keys and running console commands
158159
- [aws-mfa](https://github.com/broamski/aws-mfa) - utility for automating the reception of temporary STS tockens when MFA is enabled
@@ -349,6 +350,9 @@ Details can be found [here](https://www.terraform.io/docs/cli/run/index.html)
349350
350351
### terragrunt
351352
353+
* Terragrunt version: `0.29.2`
354+
> Terragrunt version pinned in `terragrunt.hcl` file.
355+
352356
We've also used `terragrunt` to simplify s3 bucket creation and terraform backend configuration. All you need to do is to set s3 bucket name in the `TF_REMOTE_STATE_BUCKET` env variable and run terragrunt command in the `terraform/` directory:
353357
354358
```bash
@@ -359,6 +363,43 @@ We've also used `terragrunt` to simplify s3 bucket creation and terraform backen
359363
360364
By running this `terragrunt` will create s3 bucket, configure terraform backend and then will run `terraform init` and `terraform apply` in layer-1 and layer-2 sequentially.
361365
366+
#### Apply infrastructure by layers with `terragrunt`
367+
368+
Go to layer folder `terraform/layer1-aws/` or `terraform/layer2-k8s/` and run this command:
369+
370+
```
371+
terragrunt apply
372+
```
373+
374+
> The `layer2-k8s` has a dependence on `layer1-aws`.
375+
376+
#### Target apply by `terragrunt`
377+
378+
Go to layer folder `terraform/layer1-aws/` or `terraform/layer2-k8s/` and run this command:
379+
380+
```
381+
terragrunt apply -target=module.eks
382+
```
383+
384+
> The `-target` is formed from the following parts `resource type` and `resource name`.
385+
> For example: `-target=module.eks`, `-target=helm_release.loki_stack`
386+
387+
#### Destroy infrastructure by `terragrunt`
388+
389+
To destroy both layers, run this command from `terraform/` folder:
390+
391+
```
392+
terragrant run-all destroy
393+
```
394+
395+
To destroy `layer2-k8s`, run this command from `terraform/layare2-k8s` folder:
396+
397+
```
398+
terragrunt destroy
399+
```
400+
401+
> The `layer2-k8s` has dependence from `layer1-aws` and when you destroy `layer1-aws`, `layer2-k8s` destroyed automatically.
402+
362403
## What to do after deployment
363404
364405
After applying this configuration, you will get the infrastructure described and outlined at the beginning of the document. In AWS and within the EKS cluster, the basic resources and services necessary for the operation of the EKS k8s cluster will be created.

terraform/.terragrunt-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.29.2

terraform/layer2-k8s/templates/cert-manager-values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ affinity:
1414
- matchExpressions:
1515
- key: node.kubernetes.io/lifecycle
1616
operator: In
17-
values:
17+
values:
1818
- ondemand
1919

2020
cainjector:

terraform/terragrunt.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ remote_state {
2222
encrypt = true
2323
}
2424
}
25+
26+
terragrunt_version_constraint = "0.29.2"
27+

0 commit comments

Comments
 (0)