Skip to content

Commit

Permalink
Replace terrafile
Browse files Browse the repository at this point in the history
  • Loading branch information
Neill Turner committed Dec 2, 2024
1 parent 882ae50 commit 4f12357
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 46 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ bin/fetch_config.rb
terraform/*token*
terraform/**/vendor/
terraform/*/.terraform
bin/terrafile
bin/konduit.sh

# Local .terraform directories
Expand Down
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ bin/konduit.sh:
curl -s https://raw.githubusercontent.com/DFE-Digital/teacher-services-cloud/main/scripts/konduit.sh -o bin/konduit.sh \
&& chmod +x bin/konduit.sh

bin/terrafile: ## Install terrafile to manage terraform modules
curl -sL https://github.com/coretech/terrafile/releases/download/v${TERRAFILE_VERSION}/terrafile_${TERRAFILE_VERSION}_$$(uname)_x86_64.tar.gz \
| tar xz -C ./bin terrafile

.PHONY: terrafile
terrafile: bin/terrafile
./bin/terrafile -p terraform/aks/vendor/modules \
-f terraform/aks/workspace_variables/$(CONFIG)_Terrafile
.PHONY: vendor-modules
vendor-modules:
rm -rf terraform/aks/vendor/modules
git -c advice.detachedHead=false clone --depth=1 --single-branch --branch ${TERRAFORM_MODULES_TAG} https://github.com/DFE-Digital/terraform-modules.git terraform/aks/vendor/modules/aks

tags: ##Tags that will be added to resource group on it's creation in ARM template
$(eval RG_TAGS=$(shell echo '{"Portfolio": "Early years and Schools Group", "Parent Business":"Teaching Regulation Agency", "Product" : "Find a Lost TRN", "Service Line": "Teaching Workforce", "Service": "Teacher Services", "Service Offering": "Find a Lost TRN", "Environment" : "$(ENV_TAG)"}' | jq . ))
Expand All @@ -79,9 +75,8 @@ install-fetch-config: ## Install the fetch-config script, for viewing/editing se
&& chmod +x bin/fetch_config.rb \
|| true

terraform-init: bin/terrafile
terraform-init: vendor-modules
[[ "${SP_AUTH}" != "true" ]] && az account set -s $(AZURE_SUBSCRIPTION) || true
./bin/terrafile -p terraform/aks/vendor/modules -f terraform/aks/workspace_variables/$(CONFIG)_Terrafile
terraform -chdir=terraform/aks init -backend-config workspace_variables/$(CONFIG).backend.tfvars $(backend_config) -upgrade -reconfigure
$(if $(DOCKER_IMAGE), $(eval export TF_VAR_app_docker_image=$(DOCKER_IMAGE)), $(error Missing environment variable "DOCKER_IMAGE"))

Expand Down Expand Up @@ -137,9 +132,13 @@ domain-azure-resources: set-azure-account set-azure-template-tag set-azure-resou
--name "${DNS_ZONE}domains-$(shell date +%Y%m%d%H%M%S)" --parameters "resourceGroupName=${RESOURCE_NAME_PREFIX}-${DNS_ZONE}domains-rg" 'tags=${RG_TAGS}' \
"tfStorageAccountName=${RESOURCE_NAME_PREFIX}${DNS_ZONE}domainstf" "tfStorageContainerName=${DNS_ZONE}domains-tf" "keyVaultName=${RESOURCE_NAME_PREFIX}-${DNS_ZONE}domains-kv" ${WHAT_IF}

domains-infra-init: bin/terrafile faltrn_domain set-azure-account ## make domains-infra-init - terraform init for dns core resources, eg Main FrontDoor resource
./bin/terrafile -p terraform/domains/infrastructure/vendor/modules -f terraform/domains/infrastructure/config/zones_Terrafile
.PHONY: vendor-domain-infra-modules
vendor-domain-infra-modules:
rm -rf terraform/domains/infrastructure/vendor/modules/domains
TERRAFORM_MODULES_TAG=stable
git -c advice.detachedHead=false clone --depth=1 --single-branch --branch ${TERRAFORM_MODULES_TAG} https://github.com/DFE-Digital/terraform-modules.git terraform/domains/infrastructure/vendor/modules/domains

domains-infra-init: faltrn_domain vendor-domain-infra-modules set-azure-account ## make domains-infra-init - terraform init for dns core resources, eg Main FrontDoor resource
terraform -chdir=terraform/domains/infrastructure init -reconfigure -upgrade

domains-infra-plan: domains-infra-init ## terraform plan for dns core resources
Expand All @@ -150,9 +149,12 @@ domains-infra-apply: domains-infra-init ## terraform apply for dns core resource

######################################

domains-init: bin/terrafile faltrn_domain set-azure-account ## terraform init for dns resources: make <env> domains-init
./bin/terrafile -p terraform/domains/environment_domains/vendor/modules -f terraform/domains/environment_domains/config/${CONFIG}_Terrafile
.PHONY: vendor-domain-modules
vendor-domain-modules:
rm -rf terraform/domains/environment_domains/vendor/modules/domains
git -c advice.detachedHead=false clone --depth=1 --single-branch --branch ${TERRAFORM_MODULES_TAG} https://github.com/DFE-Digital/terraform-modules.git terraform/domains/environment_domains/vendor/modules/domains

domains-init: faltrn_domain vendor-domain-modules set-azure-account ## terraform init for dns resources: make <env> domains-init
terraform -chdir=terraform/domains/environment_domains init -upgrade -reconfigure -backend-config=key=$(or $(DOMAINS_TERRAFORM_BACKEND_KEY),faltrndomains_$(DEPLOY_ENV).tfstate)

domains-plan: domains-init ## terraform plan for dns resources, eg dev.<domain_name> dns records and frontdoor routing
Expand Down
1 change: 1 addition & 0 deletions global_config/development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ AZURE_RESOURCE_PREFIX=s189t01
RESOURCE_GROUP_NAME=s189d01-tsc-${CONFIG_SHORT}-rg
ENV_TAG=Test
DOMAINS_TERRAFORM_BACKEND_KEY=faltrndomains_dev.tfstate
TERRAFORM_MODULES_TAG=main
1 change: 1 addition & 0 deletions global_config/domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ RESOURCE_GROUP_NAME=${RESOURCE_NAME_PREFIX}-${DNS_ZONE}domains-rg
KEYVAULT_NAME=${RESOURCE_NAME_PREFIX}-${DNS_ZONE}domains-kv
STORAGE_ACCOUNT_NAME=${RESOURCE_NAME_PREFIX}${DNS_ZONE}domainstf
DOMAINS_ID=faltrn
TERRAFORM_MODULES_TAG=stable
1 change: 1 addition & 0 deletions global_config/preproduction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test
AZURE_RESOURCE_PREFIX=s189t01
ENV_TAG=Test
DOMAINS_TERRAFORM_BACKEND_KEY=faltrndomains_preprod.tfstate
TERRAFORM_MODULES_TAG=testing
1 change: 1 addition & 0 deletions global_config/production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-tsc-${CONFIG_SHORT}-rg
ENV_TAG=Prod
ENVIRONMENT=production
DOMAINS_TERRAFORM_BACKEND_KEY=faltrndomains_prod.tfstate
TERRAFORM_MODULES_TAG=stable
1 change: 1 addition & 0 deletions global_config/review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test
AZURE_RESOURCE_PREFIX=s189t01
ENV_TAG=Test
DOMAINS_TERRAFORM_BACKEND_KEY=faltrndomains_review.tfstate
TERRAFORM_MODULES_TAG=main
1 change: 1 addition & 0 deletions global_config/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ RESOURCE_GROUP_NAME=${RESOURCE_PREFIX}-tsc-${CONFIG_SHORT}-rg
ENVIRONMENT=test
ENV_TAG=Test
DOMAINS_TERRAFORM_BACKEND_KEY=faltrndomains_test.tfstate
TERRAFORM_MODULES_TAG=testing
3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/development_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/preproduction_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/production_Terrafile

This file was deleted.

4 changes: 0 additions & 4 deletions terraform/aks/workspace_variables/review_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/test_Terrafile

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/domains/environment_domains/config/test_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/domains/infrastructure/config/zones_Terrafile

This file was deleted.

0 comments on commit 4f12357

Please sign in to comment.