terraform-aws-modules / terraform-aws-vpc

Terraform module to create AWS VPC resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws
Apache License 2.0
2.97k stars 4.43k forks source link

Should EIP be deleted when destroying VPC? #64

Closed mhumeSF closed 6 years ago

mhumeSF commented 6 years ago

Wanted to know why they might get left behind after tf destroy

antonbabenko commented 6 years ago

Normally, when EIP is created by this module it will be deleted as well. Here is the code - https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/main.tf#L201-L207

If you pass external_nat_ip_ids to reuse existing EIPs they won't be managed by Terraform and will persist after VPC is deleted.

mhumeSF commented 6 years ago

I think I was having issues with terragrunt. This is working as you described and EIPs are created and destroyed correctly.

felimartina commented 6 years ago

In my case the EIPs are not deleted unless I run the terraform destroy command a second time. This is, the first time I run terraform destroy I will get the following error:

aws_eip.nat.0: AuthFailure: You do not have permission to access the specified resource.
        status code: 400, request id: b8264134-37f9-487a-a59c-07c0f2f5ccb1
* module.vpc.aws_eip.nat[0] (destroy): 1 error(s) occurred:

one of those errors for each EIP that was created by the module. Thoughts?

antonbabenko commented 6 years ago

It is likely to be this issue and it was fixed in AWS provider version 1.7.1

felimartina commented 6 years ago

Ohhh i see! thank you @antonbabenko!

github-actions[bot] commented 1 year ago

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.