Open ghost opened 5 years ago
I have a similar issue, that is based on the same problem. I have multiple child R53 healthchecks created by TF and then another resource as "CALCULATED" R53 healtcheck, where I pass the IDs of all the childs.
AWS provider version: 3.9.0
It works fine when creating (childs are getting created first, then the parent which uses their IDs = all good), but it fails when I want to remove one or more of the childs (TF tries to destroy the child first, but it's still referenced in the parent):
resource "aws_route53_health_check" "child" {
for_each = var.r53_healtchecks_enabled == true ? toset(var.services) : []
failure_threshold = var.healthcheck_failure_treshold
fqdn = var.domain_name
port = var.healthcheck_port
request_interval = "30"
resource_path = "/${each.key}${var.healthcheck_path}"
search_string = var.healthcheck_expected_value
type = "HTTPS_STR_MATCH"
}
resource "aws_route53_health_check" "parent" {
count = var.r53_healtchecks_enabled == true ? 1 : 0
type = "CALCULATED"
child_health_threshold = floor(var.child_health_threshold_percentage / 100 * length(var.services))
child_healthchecks = values(aws_route53_health_check.child)[*].id
}
After removing some values from the list var.services
the error occurs (provider is trying to destroy the childs, before unplugging them from the parent):
module.route53_healthcheck.aws_route53_health_check.child["service_1"]: Destroying... [id=a7035239-0cdb-4ad7-a8e1-9470e1ca3d10]
module.route53_healthcheck.aws_route53_health_check.child["service_2"]: Destroying... [id=dcd4c4cb-6c70-4a3e-a54a-574d66391c04]
Error: InvalidInput: Invalid parameter : Health check dcd4c4cb-6c70-4a3e-a54a-574d66391c04 is still referenced from parent health check(s): adc2b973-5469-4a0c-a337-db467020dd8b
status code: 400, request id: 196c409a-c4ce-4e46-bec3-9ba1d0e184a9
Error: InvalidInput: Invalid parameter : Health check a7035239-0cdb-4ad7-a8e1-9470e1ca3d10 is still referenced from parent health check(s): adc2b973-5469-4a0c-a337-db467020dd8b
status code: 400, request id: cd9620b9-37dc-433d-b3c8-bce7933a85cc
The "create_before_destroy" workaround proposed is not working in the case when I just want to remove a couple of child healtchecks...
Same issue with provider 3.46.0
Same issue with provider version v4.67.0
aws_route53_health_check.cloudfront_total_errors_old_api_flixbus_com: Destroying... [id=ID_HEALTHCHECK01]
aws_route53_health_check.cloudfront_total_errors_global_api_flixbus_com: Destroying... [id=ID_HEALTHCHECK02]
╷
│ Error: deleting Route53 Health Check (ID_HEALTHCHECK01): InvalidInput: Invalid parameter : Health check ID_HEALTHCHECK01 is still referenced from parent health check(s): ID_PARENT_HEALTHCHECK01
│ status code: 400, request id: REQUEST_ID_01
│
│ Error: deleting Route53 Health Check (ID_HEALTHCHECK02): InvalidInput: Invalid parameter : Health check ID_HEALTHCHECK02 is still referenced from parent health check(s): ID_PARENT_HEALTHCHECK02
│ status code: 400, request id: REQUEST_ID_02
This issue was originally opened by @jessebrennan as hashicorp/terraform#22171. It was migrated here as a result of the provider split. The original body of the issue is below.
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
Terraform should successfully provision updates to children of composite health checks.
Actual Behavior
Under the right conditions these errors will occur.
Steps to Reproduce
terraform init
terraform apply
measure_latency
totrue
.terraform apply
Additional Context
This can be worked around by adding
to the child health checks.
References