Skip to content

Commit

Permalink
Merge pull request #58 from maddevsio/feature/pinned-terragrunt-version
Browse files Browse the repository at this point in the history
Feature/pinned terragrunt version
  • Loading branch information
khalezin authored May 13, 2021
2 parents 8b0cc9d + a34c590 commit 33a23d6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@ This diagram shows the namespaces used in the cluster and the services deployed
## Useful tools

- [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`
- [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`
- [terraform](https://www.terraform.io/) - terraform itself, our main development tool: `tfenv install`
- [awscli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) - console utility to work with AWS API
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) - conssole utility to work with Kubernetes API
- [kubectx + kubens](https://github.com/ahmetb/kubectx) - power tools for kubectl help you switch between Kubernetes clusters and namespaces
- [helm](https://helm.sh/docs/intro/install/) - tool to create application packages and deploy them into k8s
- [helmfile](https://github.com/roboll/helmfile) - "docker compose" for helm
- [terragrunt](https://terragrunt.gruntwork.io/) - small terraform wrapper providing DRY approach in some cases
- [terragrunt](https://terragrunt.gruntwork.io/) - small terraform wrapper providing DRY approach in some cases: `tgenv install`
- [awsudo](https://github.com/meltwater/awsudo) - simple console utility that allows running awscli commands assuming specific roles
- [aws-vault](https://github.com/99designs/aws-vault) - tool for securely managing AWS keys and running console commands
- [aws-mfa](https://github.com/broamski/aws-mfa) - utility for automating the reception of temporary STS tockens when MFA is enabled
Expand Down Expand Up @@ -349,6 +350,9 @@ Details can be found [here](https://www.terraform.io/docs/cli/run/index.html)
### terragrunt
* Terragrunt version: `0.29.2`
> Terragrunt version pinned in `terragrunt.hcl` file.
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:
```bash
Expand All @@ -359,6 +363,43 @@ We've also used `terragrunt` to simplify s3 bucket creation and terraform backen
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.
#### Apply infrastructure by layers with `terragrunt`
Go to layer folder `terraform/layer1-aws/` or `terraform/layer2-k8s/` and run this command:
```
terragrunt apply
```
> The `layer2-k8s` has a dependence on `layer1-aws`.
#### Target apply by `terragrunt`
Go to layer folder `terraform/layer1-aws/` or `terraform/layer2-k8s/` and run this command:
```
terragrunt apply -target=module.eks
```
> The `-target` is formed from the following parts `resource type` and `resource name`.
> For example: `-target=module.eks`, `-target=helm_release.loki_stack`
#### Destroy infrastructure by `terragrunt`
To destroy both layers, run this command from `terraform/` folder:
```
terragrant run-all destroy
```
To destroy `layer2-k8s`, run this command from `terraform/layare2-k8s` folder:
```
terragrunt destroy
```
> The `layer2-k8s` has dependence from `layer1-aws` and when you destroy `layer1-aws`, `layer2-k8s` destroyed automatically.
## What to do after deployment
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.
Expand Down
1 change: 1 addition & 0 deletions terraform/.terragrunt-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.29.2
2 changes: 1 addition & 1 deletion terraform/layer2-k8s/templates/cert-manager-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ affinity:
- matchExpressions:
- key: node.kubernetes.io/lifecycle
operator: In
values:
values:
- ondemand

cainjector:
Expand Down
3 changes: 3 additions & 0 deletions terraform/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ remote_state {
encrypt = true
}
}

terragrunt_version_constraint = "0.29.2"

0 comments on commit 33a23d6

Please sign in to comment.