diff --git a/.gitignore b/.gitignore index 03e8098f2..6ccc552fc 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ tags .terraform/ fetch_config.rb -bin/terrafile terraform/application/vendor terraform/domains/infrastructure/vendor terraform/domains/environment_domains/vendor diff --git a/Makefile b/Makefile index a5c71a48b..0d369fd00 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -TERRAFILE_VERSION=0.8 ARM_TEMPLATE_TAG=1.1.10 RG_TAGS={"Product" : "Refer Serious Misconduct"} REGION=UK South @@ -197,10 +196,6 @@ aks-preprod: test-cluster aks-production: production-cluster $(eval include global_config/production.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)_$$(uname -m).tar.gz \ - | tar xz -C ./bin terrafile - aks-set-azure-account: [ "${SKIP_AZURE_LOGIN}" != "true" ] && az account set -s ${AZURE_SUBSCRIPTION} || true @@ -247,10 +242,14 @@ action-group-resources: set-azure-account # make env action-group-resources ACTI az group create -l uksouth -g ${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-mn-rg --tags "Product=Refer Serious Misconduct" az monitor action-group create -n ${AZURE_RESOURCE_PREFIX}-${SERVICE_NAME} -g ${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-mn-rg --action email ${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-email ${ACTION_GROUP_EMAIL} -aks-terraform-init: composed-variables bin/terrafile aks-set-azure-account +.PHONY: vendor-modules +vendor-modules: + rm -rf terraform/application/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/application/vendor/modules/aks + +aks-terraform-init: composed-variables vendor-modules aks-set-azure-account $(if ${DOCKER_IMAGE_TAG}, , $(eval DOCKER_IMAGE_TAG=main)) - ./bin/terrafile -p terraform/application/vendor/modules -f terraform/application/config/$(CONFIG)_Terrafile terraform -chdir=terraform/application init -upgrade -reconfigure \ -backend-config=resource_group_name=${RESOURCE_GROUP_NAME} \ -backend-config=storage_account_name=${STORAGE_ACCOUNT_NAME} \ @@ -280,9 +279,12 @@ aks-domain-azure-resources: set-azure-account set-azure-template-tag set-azure-r --parameters "resourceGroupName=${RESOURCE_NAME_PREFIX}-rsmdomains-rg" 'tags=${RG_TAGS}' "environment=${DEPLOY_ENV}" \ "tfStorageAccountName=${RESOURCE_NAME_PREFIX}rsmdomainstf" "tfStorageContainerName=rsmdomains-tf" "keyVaultName=${RESOURCE_NAME_PREFIX}-rsmdomains-kv" -domains-infra-init: bin/terrafile domains composed-variables set-azure-account - ./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 + 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: domains composed-variables vendor-domain-infra-modules set-azure-account terraform -chdir=terraform/domains/infrastructure init -reconfigure -upgrade \ -backend-config=resource_group_name=${RESOURCE_GROUP_NAME} \ -backend-config=storage_account_name=${STORAGE_ACCOUNT_NAME} \ @@ -294,9 +296,12 @@ domains-infra-plan: domains domains-infra-init ## Terraform plan for DNS infras domains-infra-apply: domains domains-infra-init ## Terraform apply for DNS infrastructure (DNS zone and front door). Usage: make domains-infra-apply terraform -chdir=terraform/domains/infrastructure apply -var-file config/zones.tfvars.json ${AUTO_APPROVE} -domains-init: bin/terrafile domains composed-variables set-azure-account - ./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: domains composed-variables vendor-domain-modules set-azure-account terraform -chdir=terraform/domains/environment_domains init -upgrade -reconfigure \ -backend-config=resource_group_name=${RESOURCE_GROUP_NAME} \ -backend-config=storage_account_name=${STORAGE_ACCOUNT_NAME} \ diff --git a/global_config/domains.sh b/global_config/domains.sh index a7b764187..7faeff71d 100644 --- a/global_config/domains.sh +++ b/global_config/domains.sh @@ -2,3 +2,4 @@ AZURE_SUBSCRIPTION=s189-teacher-services-cloud-production AZURE_RESOURCE_PREFIX=s189p01 CONFIG_SHORT=dom DISABLE_KEYVAULTS=true +TERRAFORM_MODULES_TAG=stable diff --git a/global_config/preprod.sh b/global_config/preprod.sh index f2ee65e24..f9583c8ad 100644 --- a/global_config/preprod.sh +++ b/global_config/preprod.sh @@ -4,3 +4,4 @@ CONFIG_SHORT=pp AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test AZURE_RESOURCE_PREFIX=s189t01 KV_PURGE_PROTECTION=false +TERRAFORM_MODULES_TAG=testing diff --git a/global_config/production.sh b/global_config/production.sh index ae36b87ca..82da93efe 100644 --- a/global_config/production.sh +++ b/global_config/production.sh @@ -4,3 +4,4 @@ CONFIG_SHORT=pd AZURE_SUBSCRIPTION=s189-teacher-services-cloud-production AZURE_RESOURCE_PREFIX=s189p01 KV_PURGE_PROTECTION=true +TERRAFORM_MODULES_TAG=stable diff --git a/global_config/review.sh b/global_config/review.sh index 6f2c5d5c2..832b23bb7 100644 --- a/global_config/review.sh +++ b/global_config/review.sh @@ -3,3 +3,4 @@ CONFIG_SHORT=rv AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test AZURE_RESOURCE_PREFIX=s189t01 KV_PURGE_PROTECTION=false +TERRAFORM_MODULES_TAG=main diff --git a/global_config/test.sh b/global_config/test.sh index ad8eae480..f87b5b22e 100644 --- a/global_config/test.sh +++ b/global_config/test.sh @@ -4,3 +4,4 @@ CONFIG_SHORT=ts AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test AZURE_RESOURCE_PREFIX=s189t01 KV_PURGE_PROTECTION=false +TERRAFORM_MODULES_TAG=testing diff --git a/terraform/application/config/preprod_Terrafile b/terraform/application/config/preprod_Terrafile deleted file mode 100644 index b4c222c13..000000000 --- a/terraform/application/config/preprod_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/application/config/production_Terrafile b/terraform/application/config/production_Terrafile deleted file mode 100644 index 5b2b118f0..000000000 --- a/terraform/application/config/production_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "stable" diff --git a/terraform/application/config/review_Terrafile b/terraform/application/config/review_Terrafile deleted file mode 100644 index 65af53b11..000000000 --- a/terraform/application/config/review_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "main" diff --git a/terraform/application/config/test_Terrafile b/terraform/application/config/test_Terrafile deleted file mode 100644 index b4c222c13..000000000 --- a/terraform/application/config/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/preprod_Terrafile b/terraform/domains/environment_domains/config/preprod_Terrafile deleted file mode 100644 index dfce270ef..000000000 --- a/terraform/domains/environment_domains/config/preprod_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"