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

awsutils_default_vpc_deletion: DHCP options sets should also be deleted #11

Open
onitake opened this issue Jul 21, 2021 · 3 comments
Open

Comments

@onitake
Copy link

onitake commented Jul 21, 2021

Describe the Feature

The awsutils_default_vpc_deletion deletes most resources associated with each default VPC, but it misses a resource that is also created by default in a new AWS account: DHCP option sets.

These option sets are usually missed because they have a reverse dependency on a VPC, i.e. can only be deleted after it is deassociated from the VPC, or after the VPC is gone. But they should be deleted nonetheless, if a clean account without default network resources is desired.

Expected Behavior

The default DHCP option set in each region should be deleted along with each VPC.

Use Case

I'm trying to create clean AWS accounts without any leftover resources that AWS creates by default.

Describe Ideal Solution

  1. Call https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html to determine the ID of the default DHCP option set of the VPC (filter by vpc-id, return the value of result.Vpcs[0].DhcpOptionsId)
  2. Call https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateDhcpOptions.html with DhcpOptionsId="default" on the VPC
  3. Delete the VPC
  4. Call https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DeleteDhcpOptions.html on the option set

Repeat for all regions.

Alternatives Considered

N/A

Additional Context

N/A

@oneingan
Copy link

oneingan commented Oct 16, 2024

This issue seems to be stalled and is the only thing preventing us from having a clean, pristine AWS account. Is there any blocker? If it's just a matter of time, I could try submitting a PR to help.

@ramongalate
Copy link
Contributor

ramongalate commented Oct 30, 2024

I agree that the dhcp could be deleted, but the dependency graph for it is not vpc -> dhcp, its dhcp -> vcp. its used by the vpc, so we can't delete it before the vpc.

what would be nice is having a delete_default_vpc_dhcp_options, which we could then use a depends_on on the delete default vpc resource.

@ramongalate
Copy link
Contributor

also, the vpc module that most people use for it https://github.com/terraform-aws-modules/terraform-aws-vpc, uses the default dhcp for its vpc. so deleting it with the vpc might be bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants