Repository for multi-node terraform code with terragrunt on AWS cloud
- I am using terraform and terragrunt for expressing the infrastructure resources in AWS cloud.
terraform
is used to express resources in the cloud using itsaws
provider whereasterragrunt
is being used to keep theterraform
code clean and dry of configuration.- I would be creating all resources, including VPC and subnets, routing and internet gateways, so that a dedicated, isolated environment can be established for the task.
terragrunt
allows a single click deployment of all terraform code, usingterragrunt run-all apply
that can detect changes in theterragrunt
configuration and apply the diff.terragrunt
allows code to be organised in a heirarchical manner so that resources can be organised.
NOTE: These instructions are for Linux
-
aws
: v2.0sudo apt install unzip curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install
-
terraform
: v1.3.0sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get update && sudo apt-get install terraform==1.3.0
-
terragrunt
: v0.39.1TERRAGRUNT_VERSION=0.39.1 wget https://github.com/gruntwork-io/terragrunt/releases/download/v$TERRAGRUNT_VERSION/terragrunt_linux_amd64 chmod +x terragrunt_linux_amd64 mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
- Please configure your
aws
credentials by runningaws configure
after installing the cli utility. - After that, please cd into the
terragrunt/
folder, and execute,terragrunt run-all apply
command.terragrunt
with the help ofterraform
would detect that the configuration was never applied and would print out a plan of deployment. Please entery
followed by enter to proceed. It will take few minutes for the entire deployment to be complete. - EKS cluster will deployed. It will take a while to get done. Please pull the kubeconfig for the cluster using
aws eks update-kubeconfig --region <REGION> --name <CLUSTER_NAME>
. View and set yourkubectl
context for the cluster
kubectl config get-contexts
kubectl set-context <CONTEXT-NAME>