From a43b41f0eae50d4dac92b829dc67d1895ee9a3ae Mon Sep 17 00:00:00 2001 From: Aga Dufrat Date: Mon, 5 Feb 2024 15:59:32 +0000 Subject: [PATCH 1/3] Rollout data.gov.uk Fastly configuration to production We tested it in integration and staging so now rolling it out to production. --- datagovuk.tf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/datagovuk.tf b/datagovuk.tf index c984044..991d14b 100644 --- a/datagovuk.tf +++ b/datagovuk.tf @@ -32,4 +32,16 @@ module "datagovuk-staging" { variable "datagovuk_production" { type = string +} + +module "datagovuk-production" { + source = "./modules/datagovuk" + + configuration = { + environment = "production" + git_hash = var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA + probe = "/" + } + + secrets = yamldecode(var.datagovuk_production) } \ No newline at end of file From 34538b95a29d605e8ba0bdd5f87736244cd22e0c Mon Sep 17 00:00:00 2001 From: Aga Dufrat Date: Wed, 7 Feb 2024 21:08:17 +0000 Subject: [PATCH 2/3] Use dynamic block to add DGU's headers The interpolation doesn't work for production. It will be more readable to store the variables in govuk-fastly-secrets and use dynamic block in the template, which is a pattern we already use for other definitions. --- modules/datagovuk/service.tf | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/datagovuk/service.tf b/modules/datagovuk/service.tf index 85db7bc..9c8bcc9 100644 --- a/modules/datagovuk/service.tf +++ b/modules/datagovuk/service.tf @@ -71,13 +71,19 @@ resource "fastly_service_vcl" "service" { } } - header { - name = "${local.template_values["environment"]}.data.gov.uk to www.${local.template_values["environment"]}.data.gov.uk redirect location header" - action = "set" - type = "response" - destination = "http.Location" - source = "\"https://www.${local.template_values["environment"]}.data.gov.uk\" + req.url" - response_condition = "${local.template_values["environment"]}.data.gov.uk to www.${local.template_values["environment"]}.data.gov.uk redirect response condition" + dynamic "header" { + for_each = { + for c in lookup(local.template_values, "headers", []) : c.name => c + } + iterator = each + content { + name = each.key + action = each.value.action + type = each.value.type + destination = each.value.destination + source = each.value.source + response_condition = each.value.response_condition + } } response_object { From dfc61f55d833ec26ab84a4eb9ec17d10f537e252 Mon Sep 17 00:00:00 2001 From: Aga Dufrat Date: Wed, 7 Feb 2024 21:12:05 +0000 Subject: [PATCH 3/3] Use dynamic block to add DGU's response objects The interpolation doesn't work for production. It will be more readable to store the variables in govuk-fastly-secrets and use dynamic block in the template, which is a pattern we already use for other definitions. --- modules/datagovuk/service.tf | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/datagovuk/service.tf b/modules/datagovuk/service.tf index 9c8bcc9..04fbb85 100644 --- a/modules/datagovuk/service.tf +++ b/modules/datagovuk/service.tf @@ -86,10 +86,17 @@ resource "fastly_service_vcl" "service" { } } - response_object { - name = "${local.template_values["environment"]}.data.gov.uk to www.${local.template_values["environment"]}.data.gov.uk redirect synthetic response" - status = 301 - request_condition = "${local.template_values["environment"]}.data.gov.uk to www.${local.template_values["environment"]}.data.gov.uk redirect request condition" + dynamic "response_object" { + for_each = { + for c in lookup(local.template_values, "response_objects", []) : c.name => c + } + iterator = each + content { + name = each.key + status = each.value.status + request_condition = each.value.request_condition + + } } request_setting {