I know we can destroy the resources created by terraform using its terraform destory
command but let's say I don't want to use that functionality and I only have the apply
option available.
As we can pass the count
parameter to create multiple resource instances, I saw that by setting the count value to 0
terminate those instances.
example,
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t3.micro"
count = "0"
tags = {
Name = "HelloWorld"
}
}
Can we destroy all the types of resources using the count parameter by setting it 0? will it also handle the dependency of destroying other resources? (destroying the aws_security_group_rule
by destroying aws_security_group
)
Is this a good practice to terminate the resources considering I don't have the terraform destroy
option available with me? or is there any better approach to perform a similar operation?