cloudfoundry_route: doesn't appear to capture target app in state
SeanKilleen opened this issue · 0 comments
I previously had some routes that I was testing that were not linked to anything -- experimenting with creating them.
resource "cloudfoundry_route" "customer_abap05_routes" {
for_each = var.is_05provide_account ? var.customer_environments : []
domain = cloudfoundry_domain.apps_domain[0].id
space = cloudfoundry_space.abap_space.id
hostname = "sct-${lower(each.key)}-xps"
provider = cloudfoundry.abap
}
This worked as expected.
I recently updated it to add a data source for a deployed app (an SAP process I cannot control), and updated the routes to target that app, like so:
data "cloudfoundry_app" "sct_deployed_app" {
# This app is deployed by the ABAP CI/CD pipeline.
# As of now, it is hard-coded. This may change in the future, in which case we'll extract to a variable
count = var.is_05provide_account ? 1 : 0
provider = cloudfoundry.abap
name_or_id = "the-other-app"
space = cloudfoundry_space.abap_space.id
}
resource "cloudfoundry_route" "customer_abap05_routes" {
for_each = var.is_05provide_account ? var.customer_environments : []
domain = cloudfoundry_domain.apps_domain[0].id
space = cloudfoundry_space.abap_space.id
hostname = "sct-${lower(each.key)}-xps"
provider = cloudfoundry.abap
target {
app = data.cloudfoundry_app.sct_deployed_app[0].id
}
}
When I attempted to apply this change, it failed for each route with the error (example below):
Route already exists with host 'sct-[customer]-xps' for domain 'abap.apps.sctsoftwarecloud.com'.
I commented the routes, ran Terraform apply to delete them, and then uncommented the routes resource and applied to add it once more. I figured that would be the end of it.
However, today I made a change to our infrastructure and Terraform detected a change and said that the routes would be updated to add the target app once more. I checked and the association already existed. Since I was certain the change wouldn't harm anything, I proceeded to apply the change, and once more saw the Route already exists
error.
This makes me wonder if there's not a small bug in the association of the target app to routes. If a route already exists and is targeted to an app, I'd expect the CF provider to be able to update that route.
Grateful for all that you do to provide us this tooling! Happy to do anything I can to provide more information.