I add an EKS Cluster
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = "test-eks"
subnets = "${module.test_subnets.private_subnets}"
tags = "${map("Environment", "${var.stage}")}"
vpc_id = "${module.test_subnets.vpc_id}"
}
it creates a succesful cluster. I remove the above code to delete the cluster and get an error:
Error: module.eks.data.http.workstation_external_ip: configuration for module.eks.provider.http is not present; a provider configuration block is required for all operations
There is no code left from this module, but Terraform won't cleanup after itself properly.
Hi @gb-ckedzierski
I don't think this is a problem with this module, it's common error with terraform 0.11:
https://github.com/hashicorp/terraform/issues/17928
https://github.com/hashicorp/terraform/issues/16824
I think there are 2 ways around it:
terraform destroy -target=module.eks`terraform state rm module.eks.data.http.workstation_external_ipI usually do option 2.
Thanks for your help! This worked deleting those items from the state directly.
Note to future me, these are the things that needed to be deleted
terraform state rm module.eks.null_resource.tags_as_list_of_maps
terraform state rm module.eks.data.template_file.kubeconfig
terraform state rm module.eks.data.http.workstation_external_ip
terraform state rm module.eks.data.template_file.config_map_aws_auth
terraform state rm module.eks.data.template_file.userdata
I wonder if the workaround is to pass modules like recommend in the link issues? I'll test and create a PR if I find anything that could work here. Thanks again for the help!
I had to do this just now. Is this really closed?
@pessoa Yes and no, new issue is opened up here with the real fix to the issue.
I am unable to delete the EKS cluster provsioned with this module.
Here is how I provisioned the EKS cluster.
terraform destroy fails
terraform destroy -target=module.eks also fails.
It fails to delete the security group after 10 minutes.
module.eks.aws_security_group.workers: Still destroying... (ID: sg-0f2da422658faa936, 10s elapsed)
Error: Error applying plan:
1 error(s) occurred:
module.eks.aws_security_group.workers (destroy): 1 error(s) occurred:
aws_security_group.workers: DependencyViolation: resource sg-0f2da422658faa936 has a dependent object
status code: 400, request id: 5fab7838-61cf-4b1d-8b57-e1cf3360c58a
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Let me know if anybody has any suggestions for successfully deleting the cluster.
@rajpolaris
If you created any ELBs from k8s, referenced any security groups in other SG rules, enabled scale in protection (or many more things), then this will prevent terraform destroy.
Just do to the AWS console and try to delete the SG sg-0f2da422658faa936 manually and see what the error is.
@rajpolaris add delete_on_termination = true in the network_interfaces part of the aws_launch_template as mentioned here: https://github.com/terraform-providers/terraform-provider-aws/issues/1671#issuecomment-420098531. That worked for me.
Most helpful comment
Hi @gb-ckedzierski
I don't think this is a problem with this module, it's common error with terraform 0.11:
https://github.com/hashicorp/terraform/issues/17928
https://github.com/hashicorp/terraform/issues/16824
I think there are 2 ways around it:
terraform destroy -target=module.eks`terraform state rm module.eks.data.http.workstation_external_ipI usually do option 2.