diff --git a/README.md b/README.md index f36d7ec..51c3ed0 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ module "clamav" { source = "github.com/GSA-TTS/terraform-cloudgov//clamav?ref=v2.0.0-beta.1" cf_org_name = local.cf_org_name - cf_space = data.cloudfoundry_space.app_space + cf_space_name = local.cf_space_name app_name = "app_name" name = "my_clamav_name" clamav_image = "ghcr.io/gsa-tts/clamav-rest/clamav:TAG_NAME" diff --git a/clamav/main.tf b/clamav/main.tf index 9fb8a0d..724385d 100644 --- a/clamav/main.tf +++ b/clamav/main.tf @@ -1,22 +1,16 @@ -data "cloudfoundry_domain" "internal" { - name = "apps.internal" +locals { + endpoint = "${var.name}.apps.internal" } data "cloudfoundry_app" "app" { name = var.app_name org_name = var.cf_org_name - space_name = var.cf_space.name -} - -resource "cloudfoundry_route" "clamav_route" { - space = var.cf_space.id - domain = data.cloudfoundry_domain.internal.id - host = var.name + space_name = var.cf_space_name } resource "cloudfoundry_app" "clamav_api" { name = var.name - space_name = var.cf_space.name + space_name = var.cf_space_name org_name = var.cf_org_name memory = var.clamav_memory @@ -27,7 +21,7 @@ resource "cloudfoundry_app" "clamav_api" { docker_image = var.clamav_image routes = [ { - route = cloudfoundry_route.clamav_route.url + route = local.endpoint } ] environment = { diff --git a/clamav/outputs.tf b/clamav/outputs.tf index 5486c7a..9d172ce 100644 --- a/clamav/outputs.tf +++ b/clamav/outputs.tf @@ -2,10 +2,6 @@ output "app_id" { value = cloudfoundry_app.clamav_api.id } -output "route_id" { - value = cloudfoundry_route.clamav_route.id -} - output "endpoint" { - value = cloudfoundry_route.clamav_route.url + value = local.endpoint } diff --git a/clamav/tests/creation.tftest.hcl b/clamav/tests/creation.tftest.hcl index 834c2e2..735cd15 100644 --- a/clamav/tests/creation.tftest.hcl +++ b/clamav/tests/creation.tftest.hcl @@ -1,23 +1,9 @@ -mock_provider "cloudfoundry" { - mock_data "cloudfoundry_domain" { - defaults = { - id = "7dbc73bb-28d3-481f-afcc-a81545825bd0" - } - } - mock_resource "cloudfoundry_route" { - defaults = { - url = "terraform-cloudgov-clamav-test.apps.internal" - } - } -} +mock_provider "cloudfoundry" {} mock_provider "cloudfoundry-community" {} variables { - cf_org_name = "gsa-tts-devtools-prototyping" - cf_space = { - id = "e243575e-376a-4b70-b891-23c3fa1a0680" - name = "terraform-cloudgov-ci-tests" - } + cf_org_name = "gsa-tts-devtools-prototyping" + cf_space_name = "terraform-cloudgov-ci-tests" app_name = "terraform_cloudgov_app" name = "terraform-cloudgov-clamav-test" clamav_image = "ghcr.io/gsa-tts/clamav-rest/clamav:TAG" @@ -30,11 +16,6 @@ run "test_app_creation" { error_message = "App ID output must match the clamav app ID" } - assert { - condition = cloudfoundry_route.clamav_route.id == output.route_id - error_message = "Route ID output must match the ID of the route to the clamav app" - } - assert { condition = "${var.name}.apps.internal" == output.endpoint error_message = "Endpoint output must match the clamav route endpoint" diff --git a/clamav/variables.tf b/clamav/variables.tf index 259b4ba..6203c56 100644 --- a/clamav/variables.tf +++ b/clamav/variables.tf @@ -3,12 +3,9 @@ variable "cf_org_name" { description = "cloud.gov organization name" } -variable "cf_space" { - type = object({ - id = string - name = string - }) - description = "cloud.gov space resource" +variable "cf_space_name" { + type = string + description = "cloud.gov space name" } variable "app_name" {