Skip to content

Commit

Permalink
feat: rename root terragrunt.hcl to root.hlc per Terragrunt recommend…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
matihost committed Jan 14, 2025
1 parent b15e2ed commit 71f9d42
Show file tree
Hide file tree
Showing 102 changed files with 174 additions and 184 deletions.
5 changes: 2 additions & 3 deletions terraform/aws/aws-alb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -22,8 +23,7 @@ init:


run: init ## setup VPC: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR)

@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)

test: ## test ALB Nginx instance
curl http://$(shell cd stage/$(ENV) && terragrunt output public_alb_dns):80
Expand All @@ -47,7 +47,6 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/aws-alb/stage/dev/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ locals {
current_ip = "${run_cmd("--terragrunt-quiet", "dig", "+short", "myip.opendns.com", "@resolver1.opendns.com")}"
}

include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions terraform/aws/aws-apigateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -19,10 +20,10 @@ ENV := dev
init:
cd stage/$(ENV) && terragrunt init -upgrade=true

run: init ## deploy API Gateway exposing Lambda, usage: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR)
run: init ## deploy API Gateway exposing Lambda, usage: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)

test: ## invoke Lambda programatically
test: ## invoke Lambda programmatically
aws lambda invoke --function-name=$(ENV)-synthetic-ec2-tester response.json && cat response.json
@-rm -rf response.json

Expand All @@ -38,7 +39,6 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/aws-apigateway/stage/dev/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions terraform/aws/aws-ecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -14,15 +15,13 @@ else
MODE_STR := plan
endif


ENV := dev

init:
cd stage/$(ENV) && terragrunt init -upgrade=true


run: init ## setup ECS services: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR)
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)


show-state: ## show state
Expand All @@ -34,7 +33,6 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/aws-ecs/stage/dev/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion terraform/aws/aws-efs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
Expand Down
4 changes: 3 additions & 1 deletion terraform/aws/aws-github-oidc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ clean: ## clean cached plugins and data
find . -name ".terra*" -exec rm -rf {} +
find . -name "target" -exec rm -rf {} +

upgrade-providers-version: init

help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help apply destro
.PHONY: help run clean
5 changes: 3 additions & 2 deletions terraform/aws/aws-github-oidc/stage/current/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ locals {
}


include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}


terraform {
# https://github.com/gruntwork-io/terragrunt/issues/1675
source = "${find_in_parent_folders("module")}///"
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/aws-glue/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -22,7 +23,7 @@ init:


run: init ## setup Glue services: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR)
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)

run-job: ## run CopyS3 job
aws glue start-job-run --job-name CopyS3 --region us-east-1
Expand All @@ -37,7 +38,6 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/aws-glue/stage/dev/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
File renamed without changes.
11 changes: 7 additions & 4 deletions terraform/aws/aws-iam-linked/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -15,11 +16,11 @@ else
endif


init-terraform:
init:
cd stage/current && terragrunt init -upgrade=true

run: init-terraform ## usage: Usage make run MODE=plan [DEBUG=true])
cd stage/current && terragrunt validate && terragrunt $(MODE_STR)
run: init ## usage: make run MODE=plan [DEBUG=true])
cd stage/current && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)

show-state: ## show state
cd stage/current && terragrunt state list && terragrunt show
Expand All @@ -28,7 +29,9 @@ clean: ## clean cached plugins and data
find . -name ".terra*" -exec rm -rf {} +
find . -name "target" -exec rm -rf {} +

upgrade-providers-version: init

help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help apply destro
.PHONY: help run clean
4 changes: 2 additions & 2 deletions terraform/aws/aws-iam-linked/stage/current/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
File renamed without changes.
14 changes: 10 additions & 4 deletions terraform/aws/aws-iam-management/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -15,15 +16,19 @@ else
endif


init-terraform:
init:
cd stage/current && terragrunt init -upgrade=true

run: init-terraform ## usage: Usage make run MODE=plan [DEBUG=true])
cd stage/current && terragrunt validate && terragrunt $(MODE_STR)
run: init ## usage: make run MODE=plan [DEBUG=true])
cd stage/current && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)

show-state: ## show state
cd stage/current && terragrunt state list && terragrunt show

clean: ## clean cached plugins and data
find . -name ".terra*" -exec rm -rf {} +
find . -name "target" -exec rm -rf {} +

# destroy task likely not needed
# removal of IAM resource will effectively make users unable to do nothing
# and root accout login would be required to fix issues.
Expand All @@ -33,8 +38,9 @@ show-state: ## show state
# export TF_VAR_external_access_ip=$(WHOAMI) && \
# terraform plan && terraform destroy -auto-approve

upgrade-providers-version: init

help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help apply destro
.PHONY: help run clean
4 changes: 2 additions & 2 deletions terraform/aws/aws-iam-management/stage/current/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
1 change: 0 additions & 1 deletion terraform/aws/aws-instana/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
Expand Down
2 changes: 0 additions & 2 deletions terraform/aws/aws-instance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help run clean


prepare:
@[ -e "$(HOME)/.ssh/id_rsa.aws.vm" ] || { cd ~/.ssh && ssh-keygen -m PEM -t rsa -N '' -f id_rsa.aws.vm; }
8 changes: 5 additions & 3 deletions terraform/aws/aws-jenkins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ JENKISN_AGENT_AMI := jenkins-java-agent
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -27,7 +28,7 @@ init: prepare


run: init check-master-ami check-agent-ami ## setup Jenkins Master EC2 instance group, usage: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR)
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)


JENKINS_INSTANCE_PUBLIC_IP = $(shell aws ec2 describe-instances --filters 'Name=tag:Name,Values=$(ENV)-$(REGION)-jenkins-master' --output json --region $(REGION) | jq -r '.Reservations[].Instances[] | select(.State.Name == "running") | .PublicIpAddress')
Expand Down Expand Up @@ -56,7 +57,6 @@ clean: ## clean cached plugins and data
find . -name ".terra*" -exec rm -rf {} +
find . -name "target" -exec rm -rf {} +


JENKINS_AGENTS=$(shell aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' --region $(REGION) --filters "Name=tag:Name,Values=$(ENV)-$(REGION)-jenkins-agent" --output text 2>/dev/null)
destroy-jenkins-agents: ## destroy leftover Jenkins Agents
ifneq ($(JENKINS_AGENTS),)
Expand All @@ -73,7 +73,9 @@ check-master-ami:
check-agent-ami:
@[ -n "`aws ec2 describe-images --region $(REGION) --owners self --filters "Name=name,Values=$(JENKINS_AGENT_AMI)*" --query 'sort_by(Images, &CreationDate)[].ImageId'`" ] || { echo "Missing Jenkins Master AMI in current AWS account: $(JENKINS_AGENT_AMI), run prerequisites/amis/$(JENKINS_AGENT_AMI) to build AMI first"; exit 1;}

upgrade-providers-version: init

help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help apply destroy
.PHONY: help run clean
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ prepare:
help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help apply destroy
.PHONY: help init build
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ prepare:
help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help apply destroy
.PHONY: help init build
4 changes: 2 additions & 2 deletions terraform/aws/aws-jenkins/stage/dev-arm/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ locals {
current_ip = "${run_cmd("--terragrunt-quiet", "dig", "+short", "myip.opendns.com", "@resolver1.opendns.com")}"
}

include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/aws-jenkins/stage/dev/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ locals {
current_ip = "${run_cmd("--terragrunt-quiet", "dig", "+short", "myip.opendns.com", "@resolver1.opendns.com")}"
}

include {
path = find_in_parent_folders()
include "root" {
path = find_in_parent_folders("root.hcl")
}

terraform {
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions terraform/aws/aws-network-setup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEBUG := false
ifeq ($(strip $(DEBUG)),true)
TF_LOG := DEBUG
TG_FLAGS := --terragrunt-debug
endif

MODE := apply
Expand All @@ -22,7 +23,7 @@ init: prepare


run: init ## setup VPC: make run [ENV=dev] [MODE=apply]
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR)
@cd stage/$(ENV) && terragrunt validate && terragrunt $(MODE_STR) --terragrunt-non-interactive $(TG_FLAGS)

ssh: ## ssh to VPC bastion host
eval $(shell cd stage/$(ENV) && terragrunt output bastion_ssh)
Expand Down Expand Up @@ -56,12 +57,10 @@ clean: ## clean cached plugins and data

upgrade-providers-version: init


help: ## show usage and tasks (default)
@eval $$(sed -E -n 's/^([\*\.a-zA-Z0-9_-]+):.*?## (.*)$$/printf "\\033[36m%-30s\\033[0m %s\\n" "\1" "\2" ;/; ta; b; :a p' $(MAKEFILE_LIST))
.DEFAULT_GOAL := help
.PHONY: help run clean


prepare:
@[ -e "$(HOME)/.ssh/id_rsa.aws.vm" ] || { cd ~/.ssh && ssh-keygen -m PEM -t rsa -N '' -f id_rsa.aws.vm; }
Loading

0 comments on commit 71f9d42

Please sign in to comment.