hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.81k stars 9.16k forks source link

resource/aws_subnet: subnet deletion timeout is not respected when there are Lambda ENIs that cannot be deleted #35986

Open ialidzhikov opened 8 months ago

ialidzhikov commented 8 months ago

Terraform Core Version

v1.7.4

AWS Provider Version

v4.55.0 (but should be reproducible with v5.38.0)

Affected Resource(s)

Expected Behavior

In https://github.com/hashicorp/terraform-provider-aws/blob/a051f0d485a1e2f78fc7fb8a1bcda3202a7f1118/internal/service/ec2/vpc_network_interface.go#L1505-L1508 the timeout specified for a subnet deletion is not respected and the timeout is being set to at least 45mins. This breaks part of our machinery as we expect a specified timeout to a subnet deletion (5min) to be respected. Instead, the terraform process waits for 45mins for AWS Lambda ENIs to be deleted:

Error: deleting ENIs for EC2 Subnet (subnet-1234): 1 error occurred:
    * waiting for Lambda ENI (eni-1234) to become available for detachment: context canceled

Actual Behavior

The specified custom deletion timeout (5min) to aws_subnet to be respected.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

provider "aws" {
  access_key = "${var.ACCESS_KEY_ID}"
  secret_key = "${var.SECRET_ACCESS_KEY}"
  region     = "eu-west-1"
}

resource "aws_vpc" "vpc" {
  cidr_block           = "10.250.0.0/16"
  enable_dns_support   = true
  enable_dns_hostnames = true
}

resource "aws_subnet" "subnet" {
  vpc_id            = "${aws_vpc.vpc.id}"
  cidr_block        = "10.250.0.0/19"
  availability_zone = "eu-west-1c"

  timeouts {
    create = "5m"
    delete = "5m"
  }
}

Steps to Reproduce

  1. terraform apply the above config
  2. Create a Lambda ENI using the subnet
  3. terraform destroy
  4. Make sure that the subnet deletion timeout 5min is not respected (see the debug output below)

Debug Output

aws_subnet.subnet: Still destroying... [id=subnet-1234, 5m50s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 6m0s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 6m10s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 6m20s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 6m30s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 6m40s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 6m50s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 7m0s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 7m10s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 7m20s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 7m30s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 7m40s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 7m50s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 8m0s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 8m10s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 8m20s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 8m30s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 8m40s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 8m50s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 9m0s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 9m10s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 9m20s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 9m30s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 9m40s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 9m50s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 10m0s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 10m10s elapsed]
aws_subnet.subnet: Still destroying... [id=subnet-1234, 10m20s elapsed]

# after abortion

Error: deleting ENIs for EC2 Subnet (subnet-1234): 1 error occurred:
    * waiting for Lambda ENI (eni-1234) to become available for detachment: context canceled

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 8 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue