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

Rollout data.gov.uk Fastly configuration to production #63

Merged
merged 3 commits into from
Feb 9, 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
12 changes: 12 additions & 0 deletions datagovuk.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
35 changes: 24 additions & 11 deletions modules/datagovuk/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,32 @@ 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 {
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 {
Expand Down