Skip to content

Commit

Permalink
Merge pull request #27 from 18F/support-hostname-on-domain-service
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldoomgov authored Jun 13, 2023
2 parents 619844b + 5662f8d commit 7db01d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ Note that the domain must be created in cloud.gov by an OrgManager before this m

```
module "domain" {
source = "github.com/18f/terraform-cloudgov//domain?ref=v0.6.0"
source = "github.com/18f/terraform-cloudgov//domain?ref=v0.7.0"
cf_org_name = local.cf_org_name
cf_space_name = local.cf_space_name
app_name_or_id = "app_name"
cdn_plan_name = "domain"
domain_name = "my-production-domain-name"
host_name = "my-production-host-name"
}
```

Expand Down
8 changes: 5 additions & 3 deletions domain/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
locals {
service_name = (var.name == "" ? "${data.cloudfoundry_app.app.name}-${var.domain_name}" : var.name)
endpoint = (var.host_name != null ? "${var.host_name}.${var.domain_name}" : var.domain_name)
}

data "cloudfoundry_space" "space" {
Expand All @@ -25,8 +26,9 @@ data "cloudfoundry_domain" "origin_url" {
}

resource "cloudfoundry_route" "origin_route" {
domain = data.cloudfoundry_domain.origin_url.id
space = data.cloudfoundry_space.space.id
domain = data.cloudfoundry_domain.origin_url.id
hostname = var.host_name
space = data.cloudfoundry_space.space.id
target {
app = data.cloudfoundry_app.app.id
}
Expand All @@ -41,5 +43,5 @@ resource "cloudfoundry_service_instance" "external_domain_instance" {
space = data.cloudfoundry_space.space.id
service_plan = data.cloudfoundry_service.external_domain.service_plans[var.cdn_plan_name]
recursive_delete = var.recursive_delete
json_params = "{\"domains\": \"${var.domain_name}\"}"
json_params = "{\"domains\": \"${local.endpoint}\"}"
}
8 changes: 7 additions & 1 deletion domain/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ variable "cdn_plan_name" {

variable "domain_name" {
type = string
description = "DNS name users will be accessing site"
description = "Domain name users will use to access the application"
}

variable "host_name" {
type = string
description = "Host name users will use to access the application"
default = null
}

0 comments on commit 7db01d5

Please sign in to comment.