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

deleting EC2 Subnet (subnet-xxxxxxx): DependencyViolation: The subnet 'subnet-xxxxxxx' has dependencies and cannot be deleted. #1081

Closed
GanesanChandran opened this issue May 24, 2024 · 8 comments
Labels

Comments

@GanesanChandran
Copy link

Description

I have used terraform VPC module to create the VPC through Terragrunt. When i try to delete the VPC, it got hanged and throw EC2 Subnet (subnet-xxxxx): DependencyViolation error.

Versions

Module version [Required]:

Terragrunt version:
v0.55.20

Provider version(s):
registry.terraform.io/hashicorp/aws v5.42.0

Reproduction Code [Required]

  source = "terraform-aws-modules/vpc/aws"
  version = **"4.0.0"**
  name   = local.vpc_name
  cidr   = var.vpc_cidr

  azs              = var.availability_zones
  public_subnets   = var.public_subnets
  private_subnets  = var.private_subnets
  database_subnets = var.database_subnets

  create_database_subnet_group = true
  manage_default_route_table   = true
  default_route_table_tags     = { DefaultRouteTable = true }

  enable_dns_hostnames = true
  enable_dns_support   = true

  enable_nat_gateway     = true
  one_nat_gateway_per_az = true

  enable_vpn_gateway = false
  map_public_ip_on_launch = false

  manage_default_security_group  = true
  default_security_group_ingress = []
  default_security_group_egress  = []

  enable_flow_log                                 = true
  create_flow_log_cloudwatch_log_group            = true
  create_flow_log_cloudwatch_iam_role             = true
  flow_log_max_aggregation_interval               = 60
  flow_log_cloudwatch_log_group_retention_in_days = 30

  tags = var.default-tags
}

When i apply destroy command to delete the vpc, i got below.

module.vpc.aws_subnet.private[1]: Destroying... [id=subnet-xxxxx]
module.vpc.aws_subnet.private[0]: Destroying... [id=subnet-xxxxx]

Error: deleting EC2 Subnet (subnet-xxxxx): DependencyViolation: The subnet 'subnet-xxxxx' has dependencies and cannot be deleted.
│ 	status code: 400, request id: 76947801-c590-4a79-bfdb-6468693133b8
│ 
│ 

│ Error: deleting EC2 Subnet (subnet-xxxxx): DependencyViolation: The subnet 'subnet-xxxxx' has dependencies and cannot be deleted.
│ 	status code: 400, request id: eaffa1e1-870d-43e3-a32a-434fffcd75ad

It got hanged in deleting the subnet. Above two subnets are private subnets.

Expected behavior

The plan is applied, deleting the VPC and associated subnets.

Actual behavior

It will say "Still destroying" for about 20 minutes, before it gives up saying the subnet has dependencies:
module.vpc.aws_subnet.private[2]: Destroying... [id=subnet-xxxxxx]
module.vpc.aws_subnet.private[1]: Still destroying... [id=subnet-xxxxx, 19m20s elapsed]
...
Error: deleting EC2 Subnet (subnet-xxxxx): DependencyViolation: The subnet 'subnet-xxxxx' has dependencies and cannot be deleted.
│ status code: 400, request id: 76947801-c590-4a79-bfdb-6468693133b8

Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Jun 24, 2024
@GanesanChandran
Copy link
Author

Any update on this?

@github-actions github-actions bot removed the stale label Jul 1, 2024
Copy link

github-actions bot commented Aug 1, 2024

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Aug 1, 2024
@GanesanChandran
Copy link
Author

Any update on this?

@bryantbiggs
Copy link
Member

It's not a module issue so there's nothing we can do here

@github-actions github-actions bot removed the stale label Aug 11, 2024
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Sep 11, 2024
Copy link

This issue was automatically closed because of stale in 10 days

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
Copy link

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 Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants