Skip to content

Commit

Permalink
Replace terrafile
Browse files Browse the repository at this point in the history
  • Loading branch information
Neill Turner committed Nov 29, 2024
1 parent 3198cb4 commit 3c68088
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
working-directory: terraform

- name: Download vendor modules
run: make ci development terrafile
run: make ci development vendor-modules

- name: Validate
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ storage/*
# Temporary binaries
bin/fetch_config.rb
bin/konduit.sh
bin/terrafile

# Terraform
*.tfstate
Expand Down
31 changes: 18 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ SHELL :=/bin/bash

KEY_VAULT_PURGE_PROTECTION=false
ARM_TEMPLATE_TAG=1.1.6
TERRAFILE_VERSION=0.8
SERVICE_NAME=apply-for-qts
SERVICE_SHORT=afqts

Expand Down Expand Up @@ -92,23 +91,18 @@ 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:
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: install-konduit
install-konduit: bin/konduit.sh ## Install the konduit script, for accessing backend services

.PHONY: terrafile
terrafile: bin/terrafile
./bin/terrafile -p terraform/application/vendor/modules \
-f terraform/application/config/$(CONFIG)/Terrafile
.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/dfe-terraform-modules

terraform-init: composed-variables bin/terrafile set-azure-account ## Initialize terraform for AKS
terraform-init: composed-variables vendor-modules set-azure-account ## Initialize terraform for AKS
$(if $(DOCKER_IMAGE), , $(error Missing environment variable "DOCKER_IMAGE"))
$(eval TERRAFORM_BACKEND_KEY=$(or ${TERRAFORM_BACKEND_KEY},terraform.tfstate))

./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 @@ -187,7 +181,13 @@ validate-azure-domains-resources: set-production-azure-subscription set-what-if
.PHONY: deploy-azure-domains-resources
deploy-azure-domains-resources: set-production-azure-subscription check-auto-approve domains-arm-deployment # make validate-azure-domains-resources

domains-infra-init: set-production-azure-subscription set-azure-account ## make domains-infra-init - terraform init for dns core resources, eg Main FrontDoor resource
.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: set-production-azure-subscription 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 @@ -196,7 +196,12 @@ domains-infra-plan: domains-infra-init ## terraform plan for dns core resources
domains-infra-apply: domains-infra-init ## terraform apply for dns core resources
terraform -chdir=terraform/domains/infrastructure apply -var-file config/zones.tfvars.json ${AUTO_APPROVE}

domains-init: set-production-azure-subscription set-azure-account ## terraform init for dns resources: make <env> domains-init
.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: set-production-azure-subscription 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),afqtsdomains_$(CONFIG).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 @@ -4,3 +4,4 @@ CONFIG_SHORT=dv
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/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
ENABLE_KV_DIAGNOSTICS=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/development/Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/application/config/preproduction/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.

2 changes: 1 addition & 1 deletion terraform/domains/environment_domains/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "domains" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//domains/environment_domains?ref=stable"
source = "./vendor/modules/domains//domains/environment_domains"
zone = var.zone
front_door_name = var.front_door_name
resource_group_name = var.resource_group_name
Expand Down
2 changes: 1 addition & 1 deletion terraform/domains/infrastructure/main.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 3c68088

Please sign in to comment.