diff --git a/Makefile b/Makefile index 082d70aec3..d3fea47712 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ ifndef VERBOSE endif SERVICE_SHORT=ptt SERVICE_NAME=publish -TERRAFILE_VERSION=0.8 .PHONY: help help: ## Show this help @@ -55,12 +54,6 @@ install-fetch-config: ## Install utility to fetch the cli config from teacher se && chmod +x bin/fetch_config.rb \ || true -install-terrafile: ## Install terrafile to manage terraform modules - [ ! -f bin/terrafile ] \ - && 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 \ - || true - # Set "USE_DB_SETUP_COMMAND" to true for first time deployments, otherwise false. review: ## make review deploy PR_NUMBER=2222 USE_DB_SETUP_COMMAND=true $(if $(PR_NUMBER), , $(error Missing environment variable "PR_NUMBER", Please specify a name for your review app)) @@ -154,13 +147,17 @@ worker-shell: get-cluster-credentials $(if $(PR_NUMBER), $(eval export APP_ID=review-$(PR_NUMBER)) , $(eval export APP_ID=$(CONFIG_LONG))) kubectl -n ${NAMESPACE} exec -ti --tty deployment/publish-${APP_ID}-worker -- /bin/sh +.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 + ### Infra Targets From Here -deploy-init: install-terrafile +deploy-init: vendor-modules $(if $(IMAGE_TAG), , $(eval export IMAGE_TAG=main)) $(eval export TF_VAR_docker_image=ghcr.io/dfe-digital/publish-teacher-training:$(IMAGE_TAG)) az account set -s ${AZ_SUBSCRIPTION} && az account show - [ "${RUN_TERRAFILE}" = "yes" ] && ./bin/terrafile -p terraform/aks/vendor/modules -f terraform/aks/workspace_variables/$(DEPLOY_ENV)_Terrafile || true terraform -chdir=terraform/aks init -reconfigure -upgrade -backend-config=./workspace_variables/$(DEPLOY_ENV)_backend.tfvars $(backend_key) $(eval export TF_VARS=-var config_short=${CONFIG_SHORT} -var service_short=${SERVICE_SHORT} -var service_name=${SERVICE_NAME} -var azure_resource_prefix=${RESOURCE_NAME_PREFIX}) @@ -234,7 +231,13 @@ validate-domain-resources: set-what-if domain-azure-resources # make publish val deploy-domain-resources: check-auto-approve domain-azure-resources # make publish deploy-domain-resources AUTO_APPROVE=1 -domains-infra-init: set-production-subscription set-azure-account +.PHONY: vendor-domain-infra-modules +vendor-domain-infra-modules: + rm -rf terraform/custom_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/custom_domains/infrastructure/vendor/modules/domains + +domains-infra-init: set-production-subscription set-azure-account vendor-domain-infra-modules terraform -chdir=terraform/custom_domains/infrastructure init -reconfigure -upgrade \ -backend-config=workspace_variables/${DOMAINS_ID}_backend.tfvars @@ -244,7 +247,12 @@ domains-infra-plan: domains-infra-init # make publish domains-infra-plan domains-infra-apply: domains-infra-init # make publish domains-infra-apply terraform -chdir=terraform/custom_domains/infrastructure apply -var-file workspace_variables/${DOMAINS_ID}.tfvars.json ${AUTO_APPROVE} -domains-init: set-production-subscription set-azure-account +.PHONY: vendor-domain-modules +vendor-domain-modules: + rm -rf terraform/custom_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/custom_domains/environment_domains/vendor/modules/domains + +domains-init: set-production-subscription set-azure-account vendor-domain-modules terraform -chdir=terraform/custom_domains/environment_domains init -upgrade -reconfigure -backend-config=workspace_variables/${DOMAINS_ID}_${DEPLOY_ENV}_backend.tfvars domains-plan: domains-init # make publish qa domains-plan diff --git a/global_config/dv_review.sh b/global_config/dv_review.sh index 92862c894c..45dd28c142 100644 --- a/global_config/dv_review.sh +++ b/global_config/dv_review.sh @@ -4,4 +4,4 @@ CONFIG_SHORT=rv AZ_SUBSCRIPTION=s189-teacher-services-cloud-development RESOURCE_NAME_PREFIX=s189d01 CLUSTER_SHORT=dv -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=main diff --git a/global_config/find-domain.sh b/global_config/find-domain.sh index 3bdf8fe75f..b60ccd1577 100644 --- a/global_config/find-domain.sh +++ b/global_config/find-domain.sh @@ -9,4 +9,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=find -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=stable diff --git a/global_config/production.sh b/global_config/production.sh index c20f9dc001..13e181bbb2 100644 --- a/global_config/production.sh +++ b/global_config/production.sh @@ -4,4 +4,4 @@ CONFIG_SHORT=pd AZ_SUBSCRIPTION=s189-teacher-services-cloud-production RESOURCE_NAME_PREFIX=s189p01 CLUSTER_SHORT=pd -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=stable diff --git a/global_config/publish-domain.sh b/global_config/publish-domain.sh index 85a7b0fd15..77a1300d10 100644 --- a/global_config/publish-domain.sh +++ b/global_config/publish-domain.sh @@ -9,4 +9,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=publish -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=stable diff --git a/global_config/qa.sh b/global_config/qa.sh index 514920acb6..05e06431d1 100644 --- a/global_config/qa.sh +++ b/global_config/qa.sh @@ -4,4 +4,4 @@ CONFIG_SHORT=qa AZ_SUBSCRIPTION=s189-teacher-services-cloud-test RESOURCE_NAME_PREFIX=s189t01 CLUSTER_SHORT=ts -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=testing diff --git a/global_config/review.sh b/global_config/review.sh index 0362fe8ae3..4d4ad2cda5 100644 --- a/global_config/review.sh +++ b/global_config/review.sh @@ -4,4 +4,4 @@ CONFIG_SHORT=rv AZ_SUBSCRIPTION=s189-teacher-services-cloud-test RESOURCE_NAME_PREFIX=s189t01 CLUSTER_SHORT=ts -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=main diff --git a/global_config/sandbox.sh b/global_config/sandbox.sh index 52bd719957..f56440a26c 100644 --- a/global_config/sandbox.sh +++ b/global_config/sandbox.sh @@ -4,4 +4,4 @@ CONFIG_SHORT=sbx AZ_SUBSCRIPTION=s189-teacher-services-cloud-production RESOURCE_NAME_PREFIX=s189p01 CLUSTER_SHORT=pd -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=stable diff --git a/global_config/staging.sh b/global_config/staging.sh index 62b3cf7f0a..7bee789a06 100644 --- a/global_config/staging.sh +++ b/global_config/staging.sh @@ -4,4 +4,4 @@ CONFIG_SHORT=stg AZ_SUBSCRIPTION=s189-teacher-services-cloud-test RESOURCE_NAME_PREFIX=s189t01 CLUSTER_SHORT=ts -RUN_TERRAFILE=yes +TERRAFORM_MODULES_TAG=testing diff --git a/terraform/aks/workspace_variables/dv_review_Terrafile b/terraform/aks/workspace_variables/dv_review_Terrafile deleted file mode 100644 index 65af53b11d..0000000000 --- a/terraform/aks/workspace_variables/dv_review_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/production_Terrafile b/terraform/aks/workspace_variables/production_Terrafile deleted file mode 100644 index 5b2b118f00..0000000000 --- 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/qa_Terrafile b/terraform/aks/workspace_variables/qa_Terrafile deleted file mode 100644 index b4c222c13d..0000000000 --- a/terraform/aks/workspace_variables/qa_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/aks/workspace_variables/review_Terrafile b/terraform/aks/workspace_variables/review_Terrafile deleted file mode 100644 index 65af53b11d..0000000000 --- a/terraform/aks/workspace_variables/review_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/sandbox_Terrafile b/terraform/aks/workspace_variables/sandbox_Terrafile deleted file mode 100644 index 5b2b118f00..0000000000 --- a/terraform/aks/workspace_variables/sandbox_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/staging_Terrafile b/terraform/aks/workspace_variables/staging_Terrafile deleted file mode 100644 index b4c222c13d..0000000000 --- a/terraform/aks/workspace_variables/staging_Terrafile +++ /dev/null @@ -1,3 +0,0 @@ -aks: - source: "https://github.com/DFE-Digital/terraform-modules" - version: "testing" diff --git a/terraform/custom_domains/environment_domains/main.tf b/terraform/custom_domains/environment_domains/main.tf index 42f37f7672..2b0e6714c9 100644 --- a/terraform/custom_domains/environment_domains/main.tf +++ b/terraform/custom_domains/environment_domains/main.tf @@ -1,7 +1,7 @@ # Used to create domains to be managed by front door. module "domains" { for_each = var.hosted_zone - source = "git::https://github.com/DFE-Digital/terraform-modules.git//domains/environment_domains?ref=main" + source = "./vendor/modules/domains//domains/environment_domains" zone = each.key front_door_name = each.value.front_door_name resource_group_name = each.value.resource_group_name @@ -17,6 +17,6 @@ module "domains" { # Takes values from hosted_zone.domain_name.cnames (or txt_records, a-records). Use for domains which are not associated with front door. module "dns_records" { - source = "git::https://github.com/DFE-Digital/terraform-modules.git//dns/records?ref=main" + source = "./vendor/modules/domains//dns/records" hosted_zone = var.hosted_zone } diff --git a/terraform/custom_domains/infrastructure/main.tf b/terraform/custom_domains/infrastructure/main.tf index 1628da9dee..b2fee8cba0 100644 --- a/terraform/custom_domains/infrastructure/main.tf +++ b/terraform/custom_domains/infrastructure/main.tf @@ -1,5 +1,5 @@ module "domains_infrastructure" { - source = "git::https://github.com/DFE-Digital/terraform-modules.git//domains/infrastructure?ref=stable" + source = "./vendor/modules/domains//domains/infrastructure" hosted_zone = var.hosted_zone tags = var.tags deploy_default_records = var.deploy_default_records