Skip to content

Commit

Permalink
Add in the ability to unset override host
Browse files Browse the repository at this point in the history
  • Loading branch information
keirbadger committed Jan 24, 2023
1 parent 46f3933 commit fbd1380
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions fastly.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module "fastly" {
source = "./modules/fastly-frontend"

domain_name = var.fastly_domain
additional_domain_names = var.additional_fastly_domains
bare_redirect_domain_name = var.bare_redirect_domain_name
backend_address = module.dns_record.fqdn
env = var.env
Expand All @@ -25,5 +26,6 @@ module "fastly" {
shield = var.shield
surrogate_key_name = var.surrogate_key_name
run_data = var.run_data
override_host = var.override_host
}

7 changes: 7 additions & 0 deletions modules/fastly-frontend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ resource "fastly_service_v1" "fastly" {
name = local.full_domain_name
}

dynamic "domain" {
for_each = var.additional_domain_names
content {
name = var.env == "live" ? domain.value : "${var.env}-${domain.value}"
}
}
default_host = var.override_host == "true" ? local.full_domain_name : ""
default_ttl = 60
Expand Down
6 changes: 6 additions & 0 deletions modules/fastly-frontend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ variable "domain_name" {
description = "Domain name to use for this Fastly configuration"
}

variable "additional_domain_names" {
type = list(string)
description = "List of additional domain names for fastly"
default = []
}

variable "bare_redirect_domain_name" {
type = string
default = ""
Expand Down
11 changes: 10 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ variable "fastly_domain" {
type = string
}

variable "additional_fastly_domains" {
default = []
type = list(string)
}

variable "env" {
description = "Environment name"
}
Expand Down Expand Up @@ -255,8 +260,12 @@ variable "run_data" {
default = true
}


variable "sticky" {
description = "turn on sticky"
default = []
}

variable "override_host" {
description = "Used to enable or disable setting of default_host (Override host in UI) value"
default = "true"
}

0 comments on commit fbd1380

Please sign in to comment.