-
Notifications
You must be signed in to change notification settings - Fork 10.3k
second destroy (after successful first) returns 'The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created.' #32126
Copy link
Copy link
Closed
Labels
Description
Terraform Version
Terraform v1.3.3 on linux_amd64 + provider registry.terraform.io/hashicorp/aws v4.34.0Terraform Configuration Files
variable "external_acm" {
type = bool
default = false
}
variable "lb_certificate_arn" {
type = string
default = ""
description = "If running HTTPS then a valid certificate arn must be provided."
}
variable "route53_zone_id" {
type = string
default = null
description = "Route53 Zone ID for the domain served by this load balancer"
}
resource "aws_acm_certificate_validation" "certval" {
count = (var.external_acm || var.lb_certificate_arn != "" || var.route53_zone_id == null) ? 0 : 1
certificate_arn = aws_acm_certificate.cert[0].arn
validation_record_fqdns = [aws_route53_record.cert_validation[0].fqdn]
lifecycle {
create_before_destroy = true
}
}
Debug Output
https://gist.github.com/jaffel-lc/78be590f8fddae0426adbffba844f374
Expected Behavior
second destroy should complete without error (just like the first) and without destroying anything.
Actual Behavior
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
╷ │ Error: Invalid count argument
│
on ../certificate.tf line 30, in resource "aws_acm_certificate_validation" "certval":
│ 30: count = (var.external_acm || var.lb_certificate_arn != "" || var.route53_zone_id == null) ? 0 : 1
│
│ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how
any instances will be created. To work around this, use the -target argument to
│ first apply only the resources that the count depends on. ╵
Steps to Reproduce
- terraform init
- terraform apply
- terraform destroy
- terraform destroy
Additional Context
No response
References
No response
Reactions are currently unavailable