awsutils_default_vpc_deletion: DHCP options sets should also be deleted
Opened this issue · 0 comments
onitake commented
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
- 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)
- Call https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateDhcpOptions.html with DhcpOptionsId="default" on the VPC
- Delete the VPC
- 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