Skip to content

Commit

Permalink
Merge pull request #1591 from DFE-Digital/terrafile
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese authored Jul 31, 2023
2 parents b241c91 + 714fc23 commit e6d92d7
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
run: terraform fmt -check -recursive
working-directory: terraform

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

- name: Validate
run: |
terraform init -backend=false
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ tmp/*
tmp/pids/*
storage/*

# Temporary binaries
bin/fetch_config.rb
bin/konduit.sh
bin/terrafile

# Terraform
*.tfstate
.terraform
terraform/*token*
terraform/*/vendor
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SHELL :=/bin/bash
SERVICE_SHORT=afqts
KEY_VAULT_PURGE_PROTECTION=false
ARM_TEMPLATE_TAG=1.1.6
TERRAFILE_VERSION=0.8

.PHONY: help
help: ## Show this help
Expand Down Expand Up @@ -76,11 +77,20 @@ 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: terraform-init
terraform-init: set-resource-group-name set-storage-account-name set-azure-account
terraform-init: set-resource-group-name set-storage-account-name set-azure-account terrafile
$(if $(DOCKER_IMAGE), , $(error Missing environment variable "DOCKER_IMAGE"))

$(eval export TF_VAR_docker_image=$(DOCKER_IMAGE))
Expand All @@ -95,19 +105,19 @@ terraform-init: set-resource-group-name set-storage-account-name set-azure-accou

.PHONY: terraform-plan
terraform-plan: terraform-init
terraform -chdir=terraform/application plan -var-file config/$(CONFIG).tfvars.json
terraform -chdir=terraform/application plan -var-file config/$(CONFIG)/variables.tfvars.json

.PHONY: terraform-refresh
terraform-refresh: terraform-init
terraform -chdir=terraform/application refresh -var-file config/$(CONFIG).tfvars.json
terraform -chdir=terraform/application refresh -var-file config/$(CONFIG)/variables.tfvars.json

.PHONY: terraform-apply
terraform-apply: terraform-init
terraform -chdir=terraform/application apply -var-file config/$(CONFIG).tfvars.json ${AUTO_APPROVE}
terraform -chdir=terraform/application apply -var-file config/$(CONFIG)/variables.tfvars.json ${AUTO_APPROVE}

.PHONY: terraform-destroy
terraform-destroy: terraform-init
terraform -chdir=terraform/application destroy -var-file config/$(CONFIG).tfvars.json ${AUTO_APPROVE}
terraform -chdir=terraform/application destroy -var-file config/$(CONFIG)/variables.tfvars.json ${AUTO_APPROVE}

.PHONY: set-azure-resource-group-tags
set-azure-resource-group-tags: ##Tags that will be added to resource group on its creation in ARM template
Expand Down
6 changes: 3 additions & 3 deletions terraform/application/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ locals {
}

module "application_configuration" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/application_configuration?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/application_configuration"

namespace = var.namespace
environment = local.environment
Expand Down Expand Up @@ -36,7 +36,7 @@ module "application_configuration" {
}

module "web_application" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/application?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/application"

name = "web"
is_web = true
Expand All @@ -54,7 +54,7 @@ module "web_application" {
}

module "worker_application" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/application?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/application"

name = "worker"
is_web = false
Expand Down
2 changes: 1 addition & 1 deletion terraform/application/cluster_data.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "cluster_data" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/cluster_data?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/cluster_data"
name = var.cluster
}
3 changes: 3 additions & 0 deletions terraform/application/config/development/Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dfe-terraform-modules:
source: https://github.com/DFE-Digital/terraform-modules
version: main
3 changes: 3 additions & 0 deletions terraform/application/config/preproduction/Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dfe-terraform-modules:
source: https://github.com/DFE-Digital/terraform-modules
version: stable
3 changes: 3 additions & 0 deletions terraform/application/config/production/Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dfe-terraform-modules:
source: https://github.com/DFE-Digital/terraform-modules
version: stable
3 changes: 3 additions & 0 deletions terraform/application/config/review/Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dfe-terraform-modules:
source: https://github.com/DFE-Digital/terraform-modules
version: main
3 changes: 3 additions & 0 deletions terraform/application/config/test/Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dfe-terraform-modules:
source: https://github.com/DFE-Digital/terraform-modules
version: testing
4 changes: 2 additions & 2 deletions terraform/application/databases.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "redis" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/redis?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/redis"

namespace = var.namespace
environment = local.environment
Expand All @@ -15,7 +15,7 @@ module "redis" {
}

module "postgres" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/postgres?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/postgres"

namespace = var.namespace
environment = local.environment
Expand Down
2 changes: 1 addition & 1 deletion terraform/application/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
module "statuscake" {
count = var.enable_monitoring ? 1 : 0

source = "git::https://github.com/DFE-Digital/terraform-modules.git//monitoring/statuscake?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//monitoring/statuscake"

uptime_urls = compact([module.web_application.probe_url, local.external_url])
ssl_urls = compact([local.external_url])
Expand Down
2 changes: 1 addition & 1 deletion terraform/application/secrets.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "infrastructure_secrets" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/secrets?ref=testing"
source = "./vendor/modules/dfe-terraform-modules//aks/secrets"

azure_resource_prefix = var.azure_resource_prefix
service_short = var.service_short
Expand Down

0 comments on commit e6d92d7

Please sign in to comment.