Skip to content

[Enhancement]: Can't delete resources associated with ENIs #41417

@Folling

Description

@Folling

Description

Deleting subnets and security groups often fails because ENIs are created outside of terraform for various resources.

It would be nice to be able to create the ENIs within terraform, which would allow deleting the resources properly. Alternatively, perhaps terraform could delete the associated ENIs first before attempting to destroy the resources.

Affected Resource(s) and/or Data Source(s)

aws_vpc_endpoint (type "Interface")
aws_eks_cluster

Potential Terraform Configuration

resource "aws_vpc" "example" {
  instance_tenancy     = "default"
  enable_dns_support   = true
  enable_dns_hostnames = true

  cidr_block = "10.0.0.0/16"
}

data "aws_availability_zone" "example" {
  zone_id = "euc1-az1"
}

resource "aws_subnet" "example" {
  for_each = toset(var.network_config.availability_zones)

  vpc_id               = aws_vpc.example.ud
  availability_zone_id = data.aws_availability_zone.example.id
  cidr_block           = "10.1.0.0/24"
}

data "aws_vpc_endpoint_service" "ecr_api" {
  service      = "ecr.api"
  service_type = "Interface"
}

resource "aws_vpc_endpoint" "ecr_api" {
  vpc_id              = aws_vpc.example.id
  service_name        = data.aws_vpc_endpoint_service.ecr_api.service_name
  vpc_endpoint_type   = "Interface"
  private_dns_enabled = true
  subnet_ids          = [aws_subnet.example.id]
}

References

hashicorp/terraform#10272

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequests to existing resources that expand the functionality or scope.needs-triageWaiting for first response or review from a maintainer.service/ec2Issues and PRs that pertain to the ec2 service.service/vpcIssues and PRs that pertain to the vpc service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions