Skip to content

Commit

Permalink
Merge pull request #431 from DFE-Digital/2158-replace-terrafile
Browse files Browse the repository at this point in the history
Replace terrafile
  • Loading branch information
RMcVelia authored Dec 5, 2024
2 parents ce35567 + 56f462c commit 81fac59
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ tmp/pids/*

.terraform
terraform/aks/vendor
terraform/custom_domains/environment_domains/vendor
terraform/custom_domains/infrastructure/vendor
terraform.tfstate*
bin/terrafile
bin/konduit.sh
bin/fetch_config.rb
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,16 @@ production: production-cluster
ci:
$(eval export AUTO_APPROVE=-auto-approve)

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-azure-account:
az account set -s ${AZ_SUBSCRIPTION}

terraform-init: install-terrafile set-azure-account
terraform-init: set-azure-account
$(if $(IMAGE_TAG), , $(eval export IMAGE_TAG=main))
$(eval export TF_VAR_app_docker_image=ghcr.io/dfe-digital/check-childrens-barred-list:$(IMAGE_TAG))

$(if $(APP_NAME), $(eval KEY_PREFIX=$(APP_NAME)), $(eval KEY_PREFIX=$(ENVIRONMENT)))
./bin/terrafile -p terraform/aks/vendor/modules -f terraform/aks/config/$(CONFIG)_Terrafile
rm -rf terraform/aks/vendor/modules/aks
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
terraform -chdir=terraform/aks init -upgrade -reconfigure \
-backend-config=resource_group_name=${RESOURCE_GROUP_NAME} \
-backend-config=storage_account_name=${STORAGE_ACCOUNT_NAME} \
Expand Down Expand Up @@ -135,6 +130,9 @@ dns:
$(eval include global_config/dns-domain.sh)

domains-infra-init: set-azure-account
rm -rf terraform/custom_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/custom_domains/infrastructure/vendor/modules/domains

terraform -chdir=terraform/custom_domains/infrastructure init -reconfigure -upgrade \
-backend-config=config/${DOMAINS_ID}_backend.tfvars

Expand All @@ -145,6 +143,8 @@ domains-infra-apply: domains-infra-init # make dns domains-infra-apply
terraform -chdir=terraform/custom_domains/infrastructure apply -var-file config/${DOMAINS_ID}.tfvars.json ${AUTO_APPROVE}

domains-init: set-azure-account
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
$(if $(PR_NUMBER), $(eval DEPLOY_ENV=${PR_NUMBER}))
terraform -chdir=terraform/custom_domains/environment_domains init -upgrade -reconfigure -backend-config=config/${DOMAINS_ID}_${DEPLOY_ENV}_backend.tfvars

Expand Down
1 change: 1 addition & 0 deletions global_config/dns-domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ KEYVAULT_NAME=${RESOURCE_NAME_PREFIX}-${DNS_ZONE}domains-kv
STORAGE_ACCOUNT_NAME=${RESOURCE_NAME_PREFIX}${DNS_ZONE}domainstf
DOMAINS_ID=ccbl
RUN_TERRAFILE=yes
TERRAFORM_MODULES_TAG=stable
1 change: 1 addition & 0 deletions global_config/preproduction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ AZURE_RESOURCE_PREFIX=s189t01
RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg
KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-kv
STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}tfstate${CONFIG_SHORT}sa
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 @@ -7,3 +7,4 @@ AZURE_RESOURCE_PREFIX=s189p01
RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg
KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-kv
STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}tfstate${CONFIG_SHORT}sa
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 @@ -7,3 +7,4 @@ AZURE_RESOURCE_PREFIX=s189t01
RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg
KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-kv
STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}tfstate${CONFIG_SHORT}sa
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 @@ -7,3 +7,4 @@ AZURE_RESOURCE_PREFIX=s189t01
RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg
KEYVAULT_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-kv
STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}tfstate${CONFIG_SHORT}sa
TERRAFORM_MODULES_TAG=main
3 changes: 0 additions & 3 deletions terraform/aks/config/preproduction_Terrafile

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions terraform/custom_domains/environment_domains/main.tf
Original file line number Diff line number Diff line change
@@ -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=stable"
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
Expand All @@ -15,6 +15,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=stable"
source = "./vendor/modules/domains//dns/records"
hosted_zone = var.hosted_zone
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion terraform/custom_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 81fac59

Please sign in to comment.