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 5, 2024
1 parent 2623832 commit d8c5938
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 36 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ tags

.terraform/
fetch_config.rb
bin/terrafile
terraform/application/vendor
terraform/domains/infrastructure/vendor
terraform/domains/environment_domains/vendor
Expand Down
27 changes: 16 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
TERRAFILE_VERSION=0.8
ARM_TEMPLATE_TAG=1.1.10
RG_TAGS={"Product" : "Refer Serious Misconduct"}
REGION=UK South
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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} \
Expand Down Expand Up @@ -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} \
Expand All @@ -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} \
Expand Down
1 change: 1 addition & 0 deletions global_config/domains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions global_config/preprod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions global_config/production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions global_config/review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions global_config/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions terraform/application/config/preprod_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/application/config/production_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/application/config/review_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/application/config/test_Terrafile

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 d8c5938

Please sign in to comment.