diff --git a/terraform/prod/main.tf b/terraform/prod/main.tf index 41f64cf4c2..963d3e7d3b 100644 --- a/terraform/prod/main.tf +++ b/terraform/prod/main.tf @@ -85,15 +85,16 @@ resource "cloudfoundry_service_instance" "redis" { } ### -# ClamAV networking +# Route mapping # The following lines should be commented out for the initial `terraform apply` # run to bootstrap the application. -# Run them after the ttahub and ClamAV apps have all been deployed +# Run them after the ttahub app has been deployed and after +# `cf create-private-domain hhs-acf-ohs-tta ttahub.ohs.acf.hhs.gov` +# has been run manually by an Org Manager ### -data "cloudfoundry_app" "clamav_api" { - name_or_id = var.clamav_api_app_name - space = data.cloudfoundry_space.space.id +data "cloudfoundry_domain" "url" { + name = var.prod_url } data "cloudfoundry_app" "ttahub" { @@ -101,6 +102,37 @@ data "cloudfoundry_app" "ttahub" { space = data.cloudfoundry_space.space.id } +resource "cloudfoundry_route" "production_route" { + domain = data.cloudfoundry_domain.url.id + space = data.cloudfoundry_space.space.id + target { + app = data.cloudfoundry_app.ttahub.id + } +} + +data "cloudfoundry_service" "external_domain" { + name = "external-domain" +} + +resource "cloudfoundry_service_instance" "production_domain" { + name = "domain-${var.env}" + space = data.cloudfoundry_space.space.id + service_plan = data.cloudfoundry_service.external_domain.service_plans["domain"] + json_params = "{\"domains\": \"${var.prod_url}\"}" +} + +### +# ClamAV networking +# The following lines should be commented out for the initial `terraform apply` +# run to bootstrap the application. +# Run them after the ttahub and ClamAV apps have all been deployed +### + +data "cloudfoundry_app" "clamav_api" { + name_or_id = var.clamav_api_app_name + space = data.cloudfoundry_space.space.id +} + resource "cloudfoundry_network_policy" "clamav_routing" { policy { source_app = data.cloudfoundry_app.ttahub.id diff --git a/terraform/prod/variables.tf b/terraform/prod/variables.tf index 27d44dd6f0..e4afbd10fe 100644 --- a/terraform/prod/variables.tf +++ b/terraform/prod/variables.tf @@ -50,3 +50,9 @@ variable "clamav_api_app_name" { description = "app name for clamav api server" default = "clamav-api-ttahub-prod" } + +variable "prod_url" { + type = string + description = "Production URL endpoint" + default = "ttahub.ohs.acf.hhs.gov" +}