Skip to content

Commit

Permalink
Merge pull request #120 from alphagov/template-tld-redirects
Browse files Browse the repository at this point in the history
Use variable for domain for tld redirects service
  • Loading branch information
theseanything authored Oct 18, 2024
2 parents 3f1acc9 + 7d9f510 commit 7aac937
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tld-redirect/service.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
locals {
secrets = yamldecode(var.secrets)
}

resource "fastly_service_vcl" "service" {
name = "${title(var.environment)} TLD Redirect"
comment = ""

domain {
name = "gov.uk"
name = local.secrets["domain"]
}

vcl {
main = true
name = "main"
content = file("${path.module}/tldredirect.vcl")
content = templatefile("${path.module}/tldredirect.vcl.tftpl", local.secrets)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sub vcl_error {
if (obj.status == 802) {
set obj.status = 301;
set obj.response = "Moved Permanently";
set obj.http.Location = "https://www.gov.uk" req.url;
set obj.http.Location = "https://www.${domain}" req.url;
set obj.http.Strict-Transport-Security = "max-age=63072000; preload";
}

Expand Down
5 changes: 5 additions & 0 deletions tld-redirect/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ variable "environment" {
type = string
default = "production"
}

variable "secrets" {

Check warning on line 6 in tld-redirect/variables.tf

View workflow job for this annotation

GitHub Actions / tflint

`secrets` variable has no type
default = {}
}

0 comments on commit 7aac937

Please sign in to comment.