From fff2ed1147bffb58885e830b80742ff1836cba7f Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Mon, 2 Dec 2024 14:37:57 +0000 Subject: [PATCH] Replace terrafile --- .github/workflows/lint.yml | 2 +- .gitignore | 1 - Makefile | 30 ++++++++++--------- global_config/development.sh | 1 + global_config/domain.sh | 1 + global_config/preproduction.sh | 1 + global_config/production.sh | 1 + global_config/review.sh | 1 + global_config/test.sh | 1 + .../workspace_variables/development_Terrafile | 3 -- .../preproduction_Terrafile | 3 -- .../workspace_variables/production_Terrafile | 3 -- .../aks/workspace_variables/review_Terrafile | 4 --- .../aks/workspace_variables/test_Terrafile | 3 -- .../config/development_Terrafile | 3 -- .../config/preproduction_Terrafile | 3 -- .../config/production_Terrafile | 3 -- .../environment_domains/config/test_Terrafile | 3 -- .../infrastructure/config/zones_Terrafile | 3 -- 19 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 terraform/aks/workspace_variables/development_Terrafile delete mode 100644 terraform/aks/workspace_variables/preproduction_Terrafile delete mode 100644 terraform/aks/workspace_variables/production_Terrafile delete mode 100644 terraform/aks/workspace_variables/review_Terrafile delete mode 100644 terraform/aks/workspace_variables/test_Terrafile delete mode 100644 terraform/domains/environment_domains/config/development_Terrafile delete mode 100644 terraform/domains/environment_domains/config/preproduction_Terrafile delete mode 100644 terraform/domains/environment_domains/config/production_Terrafile delete mode 100644 terraform/domains/environment_domains/config/test_Terrafile delete mode 100644 terraform/domains/infrastructure/config/zones_Terrafile diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 60d915de5..3fe1ba519 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -53,7 +53,7 @@ jobs: working-directory: terraform - name: Download vendor modules - run: make ci development terrafile + run: make ci development vendor-modules - name: Validate run: | diff --git a/.gitignore b/.gitignore index 5bcefac1b..17a49924e 100644 --- a/.gitignore +++ b/.gitignore @@ -71,7 +71,6 @@ bin/fetch_config.rb terraform/*token* terraform/**/vendor/ terraform/*/.terraform -bin/terrafile bin/konduit.sh # Local .terraform directories diff --git a/Makefile b/Makefile index d0b8c2e48..8c12467bc 100644 --- a/Makefile +++ b/Makefile @@ -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 . )) @@ -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")) @@ -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 @@ -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 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 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. dns records and frontdoor routing diff --git a/global_config/development.sh b/global_config/development.sh index afa21368b..4715fb9c9 100644 --- a/global_config/development.sh +++ b/global_config/development.sh @@ -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 diff --git a/global_config/domain.sh b/global_config/domain.sh index e4a074183..2c91f4f50 100644 --- a/global_config/domain.sh +++ b/global_config/domain.sh @@ -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 diff --git a/global_config/preproduction.sh b/global_config/preproduction.sh index 476513a4e..8f4bbfcea 100644 --- a/global_config/preproduction.sh +++ b/global_config/preproduction.sh @@ -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 diff --git a/global_config/production.sh b/global_config/production.sh index 7b09021fa..366704885 100644 --- a/global_config/production.sh +++ b/global_config/production.sh @@ -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 diff --git a/global_config/review.sh b/global_config/review.sh index b2fb56fbb..650e701f8 100644 --- a/global_config/review.sh +++ b/global_config/review.sh @@ -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 diff --git a/global_config/test.sh b/global_config/test.sh index b00b7b103..4d02acd62 100644 --- a/global_config/test.sh +++ b/global_config/test.sh @@ -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 diff --git a/terraform/aks/workspace_variables/development_Terrafile b/terraform/aks/workspace_variables/development_Terrafile deleted file mode 100644 index 65af53b11..000000000 --- a/terraform/aks/workspace_variables/development_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "main" diff --git a/terraform/aks/workspace_variables/preproduction_Terrafile b/terraform/aks/workspace_variables/preproduction_Terrafile deleted file mode 100644 index 5b2b118f0..000000000 --- a/terraform/aks/workspace_variables/preproduction_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "stable" diff --git a/terraform/aks/workspace_variables/production_Terrafile b/terraform/aks/workspace_variables/production_Terrafile deleted file mode 100644 index 5b2b118f0..000000000 --- a/terraform/aks/workspace_variables/production_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "stable" diff --git a/terraform/aks/workspace_variables/review_Terrafile b/terraform/aks/workspace_variables/review_Terrafile deleted file mode 100644 index fa0b42c00..000000000 --- a/terraform/aks/workspace_variables/review_Terrafile +++ /dev/null @@ -1,4 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "main" - \ No newline at end of file diff --git a/terraform/aks/workspace_variables/test_Terrafile b/terraform/aks/workspace_variables/test_Terrafile deleted file mode 100644 index b4c222c13..000000000 --- a/terraform/aks/workspace_variables/test_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/domains/environment_domains/config/development_Terrafile b/terraform/domains/environment_domains/config/development_Terrafile deleted file mode 100644 index dfce270ef..000000000 --- a/terraform/domains/environment_domains/config/development_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -domains: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/domains/environment_domains/config/preproduction_Terrafile b/terraform/domains/environment_domains/config/preproduction_Terrafile deleted file mode 100644 index dfce270ef..000000000 --- a/terraform/domains/environment_domains/config/preproduction_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -domains: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/domains/environment_domains/config/production_Terrafile b/terraform/domains/environment_domains/config/production_Terrafile deleted file mode 100644 index 58e60b3c8..000000000 --- a/terraform/domains/environment_domains/config/production_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -domains: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "stable" diff --git a/terraform/domains/environment_domains/config/test_Terrafile b/terraform/domains/environment_domains/config/test_Terrafile deleted file mode 100644 index dfce270ef..000000000 --- a/terraform/domains/environment_domains/config/test_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -domains: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/domains/infrastructure/config/zones_Terrafile b/terraform/domains/infrastructure/config/zones_Terrafile deleted file mode 100644 index 58e60b3c8..000000000 --- a/terraform/domains/infrastructure/config/zones_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -domains: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "stable"