Skip to content

Commit

Permalink
Use variable for domain for tld redirects service
Browse files Browse the repository at this point in the history
This allows us to create tld redirect services for staging and
integration.
  • Loading branch information
theseanything committed Oct 18, 2024
1 parent 3f1acc9 commit 56c6f96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tld-redirect/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ resource "fastly_service_vcl" "service" {
comment = ""

domain {
name = "gov.uk"
name = var.domain
}

vcl {
main = true
name = "main"
content = file("${path.module}/tldredirect.vcl")
content = templatefile("${path.module}/tldredirect.vcl.tftpl", { domain = var.domain })
}
}
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 "domain" {
type = string
default = "gov.uk"
}

0 comments on commit 56c6f96

Please sign in to comment.