terraform-provider-cloudfoundry
terraform-provider-cloudfoundry copied to clipboard
Wrong route found with same domain and host
Hello everyone,
we have a frontend and backend on the same domain and hostname on cloudfoundry, only the backend is on the path "/api" while the frontend is on the root path.
Now when we wanted to import the frontend route into terraform with the following configuration
data "cloudfoundry_domain" "public" {
name = "test.com"
}
data "cloudfoundry_route" "frontend-route" {
domain = data.cloudfoundry_domain.public.id
hostname = "test123"
}
data "cloudfoundry_route" "backend-route" {
domain = data.cloudfoundry_domain.public.id
hostname = "test123"
path = "/api"
}
Now when i use terraform plan
with this config, the frontend-route and backend-route have the same id. This is because cloudfoundry finds multiple routes with the given domain and hostname. This provider then only uses the first result, which can be seen here.
This is wrong in our case, as the first result is the backend route, so the fronted route has the wrong id. As there is no way for us to get the correct id of the route, we had to hardcode the id in our config file.
I don't really know if there is a way to get the exact route with correct host, domain and path, but if there is it would be nice to change the existing code so it finds the correct route.