If the resource(Lets call it foo) is deployed with the help of data source, If the resource(bar) which is referred by data source is already destroyed by manually or by accident, terraform destroy fails while destroying the resource(foo)
data "aws_security_group" "selected" {
id = "SG-ID"
}
output "group_name" {
value = "${aws_security_group.name}"
}
If we try to destory above resource when resource which id (SG-ID) we provided is no more available, Terraform will fail to destroy the resource
It should destroy the resources regardless of resources availbility which are refered by data source.
It fails to destroy resources
@frezbo
This issue has been automatically migrated to terraform-providers/terraform-provider-aws#5082 because it looks like an issue with that provider. If you believe this is _not_ an issue with the provider, please reply to terraform-providers/terraform-provider-aws#5082.
@tombuildsstuff I don't think this is specific to aws, any other providers data resource should also exhibit this behavior, am I missing context?
@bflad thanks, any suggestions or insights into how to solve this, happy to raise PR if its a simple fix
In a problem that feels related, if you tweak the configuration of a resource to make it invalid, it will no longer destroy.
For example, I had this piece of configuration:
resource "aws_route53_record" "my_record" {
zone_id = "[redacted]"
name = "[redacted]"
type = "A"
alias {
evaluate_target_health = false
name = "[redacted]"
zone_id = "[redacted]"
}
}
I accidentally commented out the zone_id line. Then, when I tried to destroy this resource, I got the following error:
Error: aws_route53_record.my_record: "zone_id": required field is not set
I'm asking Terraform to destroy the resource. Why do I care that my configuration is missing a required field?
It feels like both the missing data source issue (which I have also been suffering) and this issue could be related to Terraform fully validating its config before running a destroy. The validation needed before destroying is much slimmer than that needed before planning and applying.
Hello! :robot:
This issue seems to be covering the same problem or request as #15386, so we're going to close it just to consolidate the discussion over there. Thanks!
Problem Statement-
If the resource(Lets call it foo) is deployed with the help of data source, If the resource(bar) which is referred by data source is already destroyed by manually or by accident, terraform destroy fails while destroying the resource(foo)
Terraform Version - v0.11.6
For example -
data "aws_security_group" "selected" {
id = "SG-ID"
}output "group_name" {
value = "${aws_security_group.name}"
}If we try to destory above resource when resource which id (SG-ID) we provided is no more available, Terraform will fail to destroy the resource
Expected Behavior
It should destroy the resources regardless of resources availbility which are refered by data source.
Actual Behavior
It fails to destroy resources
Steps to Reproduce
- Use data source resource while creating the resource (Terraform deploy)
- Destroy the resource which data source is referring to (manual step)
- Try to Destroy the resource (Terraform destroy)
What was the work around to get the destroy to start working as usual?
Most helpful comment
In a problem that feels related, if you tweak the configuration of a resource to make it invalid, it will no longer destroy.
For example, I had this piece of configuration:
I accidentally commented out the
zone_idline. Then, when I tried to destroy this resource, I got the following error:I'm asking Terraform to destroy the resource. Why do I care that my configuration is missing a required field?
It feels like both the missing data source issue (which I have also been suffering) and this issue could be related to Terraform fully validating its config before running a destroy. The validation needed before destroying is much slimmer than that needed before planning and applying.