Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Delete Module #108

Closed
1 of 4 tasks
gb-ckedzierski opened this issue Aug 27, 2018 · 8 comments
Closed
1 of 4 tasks

Cannot Delete Module #108

gb-ckedzierski opened this issue Aug 27, 2018 · 8 comments

Comments

@gb-ckedzierski
Copy link

I have issues deleting module.

I'm submitting a...

  • bug report
  • feature request
  • support request
  • kudos, thank you, warm fuzzy

What is the current behavior?

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.

If this is a bug, how to reproduce? Please include a code sample if relevvant.

  • Create a cluster
  • Remove code to delete cluster.

What's the expected behavior?

  • When I remove the code, the instance should be removed.

Are you able to fix this problem and submit a PR? Link here if you have already.

Environment details

  • Affected module version:
  • OS: TFE
  • Terraform version: v0.11.7

Any other relevant info

@max-rocket-internet
Copy link
Contributor

Hi @gb-ckedzierski
I don't think this is a problem with this module, it's common error with terraform 0.11:
hashicorp/terraform#17928
hashicorp/terraform#16824

I think there are 2 ways around it:

  1. Instead of removing the module definition, you can run terraform destroy -target=module.eks`
  2. Just run terraform state rm module.eks.data.http.workstation_external_ip

I usually do option 2.

@gb-ckedzierski
Copy link
Author

gb-ckedzierski commented Aug 28, 2018

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!

@pessoa
Copy link

pessoa commented Oct 14, 2018

I had to do this just now. Is this really closed?

@gb-ckedzierski
Copy link
Author

@pessoa Yes and no, new issue is opened up here with the real fix to the issue.

@rajpolaris
Copy link

I am unable to delete the EKS cluster provsioned with this module.
Here is how I provisioned the EKS cluster.

https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/examples/eks_test_fixture/main.tf

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.

@max-rocket-internet
Copy link
Contributor

@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.

@simowaer
Copy link
Contributor

@rajpolaris add delete_on_termination = true in the network_interfaces part of the aws_launch_template as mentioned here: hashicorp/terraform-provider-aws#1671 (comment). That worked for me.

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants