Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace terrafile #4729

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ifndef VERBOSE
endif
SERVICE_SHORT=ptt
SERVICE_NAME=publish
TERRAFILE_VERSION=0.8

.PHONY: help
help: ## Show this help
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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})

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion global_config/dv_review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/find-domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/publish-domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/review.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion global_config/staging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/dv_review_Terrafile

This file was deleted.

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

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/qa_Terrafile

This file was deleted.

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

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/sandbox_Terrafile

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/aks/workspace_variables/staging_Terrafile

This file was deleted.

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=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
Expand All @@ -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
}
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
Loading