-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google_compute_url_map: cannot delete google_compute_backend_service #4543
Comments
So I have found a way around the issue by using the resource "random_id" "url_map" {
keepers = {
# Generate a new id each time the instance list changes
instances = base64encode(jsonencode(local.instances))
}
byte_length = 1
}
resource "google_compute_url_map" "default" {
name = "default-${random_id.url_map.hex}"
default_service = google_compute_backend_service.default["a-vm"].self_link
dynamic "host_rule" {
for_each = keys(jsondecode(base64decode(random_id.url_map.keepers.instances)))
content {
hosts = ["${host_rule.value}.example.com"]
path_matcher = host_rule.value
}
}
dynamic "path_matcher" {
for_each = keys(jsondecode(base64decode(random_id.url_map.keepers.instances)))
content {
name = path_matcher.value
default_service = google_compute_backend_service.default[path_matcher.value].self_link
}
}
lifecycle {
create_before_destroy = true
}
} This will cause the It is not really solving the underlying issue of the wrong order of deletion of resources though. |
@JanMa your provider's version is old. Can you upgrade it and then try to see if you can repro the issue? If you still see the issue, please attach the full debug log and |
Hello @edwardmedia , the described issue still occurs with the latest provider version. After creating all resources with the attached config file and then trying to remove the line
If I have some more time I will add the full |
@JanMa waiting for your debug logs. Thanks |
@ndmckinley I can repro this issue on v3.20.0. |
Unfortunately this issue is a combination between a core terraform issue and a GCP issue, and is not resolvable. :( The two issues are:
|
* Mark BQ's materialized view query as ForceNew * add acctest to update BigQuery Materialized View Signed-off-by: Modular Magician <[email protected]>
* Mark BQ's materialized view query as ForceNew * add acctest to update BigQuery Materialized View Signed-off-by: Modular Magician <[email protected]>
Hi @nat-henderson, do these two issues you mention still exist in 2023? |
@zymotik Hi there - unfortunately so; the former is unlikely to change, in my view. For the latter, you can check https://cloud.google.com/compute/docs/reference/rest/v1/backendServices and see that there is no reference to url maps, and no |
There is an open feature request to get the required 'in use by' information added to the |
So unless I want to use the
|
The random id solution didn't change the error I receive as it's not allowing the deletion at all due to a backend service using it. In my use case, I am replacing a backend serverless NEG with a different one but for the same path via the URL map. I receive the same error as linked above seemingly caused by the same issue of order of operations. I'm not sure what a solution here is except manually going in and deleting items in GCP and then running Terraform to recreate them which is not ideal. |
still happens with terraform 1.5.1 and TGP 5.26.0 |
Unfortunately it is unlikely this will ever get resolved in the terraform provided until the API feature request is completed https://issuetracker.google.com/issues/257459514. Our best option is to get as many people and companies to post on this feature request issue, and /or reach out to Google reps until it gets implemented. |
The response body for the |
With their latest update, I believe this could now be fixed |
Checked v5.29.1 and it's still an issue. |
v5.33.0 as well. Noting that this was stated on 2024-05-14, which is exactly what I need atm:
|
It looks like this was implemented in May. Can someone look into updating the provider to make use of it? |
I am running into it in 6.7.0 as well. |
I'm also having this issue, on 6.6.0 but I guess it is an issue in the most recent ones too |
Hello folks, this dependencies issue are commonly solved by adding a lifecycle block. Random names should not be required. I will open a PR soon. |
@maxi-cit did you end up writing a solution with lifecycle block somewhere? Because I could not make a solution with lifecycle block before, so I'm interested to see this. Also, I tested with 6.7.0 today, and it is working as intended at the moment. I did not use lifecycle block either. It might be that there were some changes in google's api rather than the provider. |
Also interested in the solution ? |
@maxi-cit I would also be interested in a solution using lifecycle blocks as I was not able to solve it with any lifecycle block combination I have tried so far. I also tested it with provider version 6.14.1 today and the issue still exists and gives us a hard time when it comes to removing backends from a load balancer configuration. |
Community Note
Terraform Version
Terraform v0.12.9
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
When an element from the
local.instances
group gets removed, Terraform should remove allcorresponding resources and update the
google_compute_url_map
resource accordingly.Actual Behavior
Instead of first updating the
google_compute_url_map
, Terraform tries to delete thegoogle_compute_backend_service
which causes the following error:I tried various combinations of
lifecycle { create_before_destroy = true }
and explicitdepends_on
blocks but i can cannot get this working.Note: Adding further entries to the
local.instances
list works just fine.Steps to Reproduce
terraform apply
"d-vm": "europe-west1-b"
terraform apply
againb/308569900
The text was updated successfully, but these errors were encountered: