How do I delete my Network Load Balancer that's associated with VPC endpoint services (PrivateLink)?

3 minute read
0

I have a Network Load Balancer that's associated with Amazon Virtual Private Cloud (Amazon VPC) endpoint services (PrivateLink). How do I delete the Network Load Balancer?

Short description

If you try to delete a Network Load Balancer that's associated with PrivateLink, you receive the error Network Load Balancer is currently associated with another service. Before you can delete a Network Load Balancer, you must first disassociate it from any associated VPC endpoint services.

Resolution

First verify that the Network Load Balancer that you're trying to delete isn't associated with VPC endpoint services. If the load balancer is associated with VPC endpoint services, make sure to follow the below steps:

  1. Reject the endpoint connections on the endpoint service.
  2. Disassociate the Network Load Balancer from the endpoint service.
  3. Delete the Network Load Balancer.

You can use the Amazon VPC console or the AWS Command Line Interface (AWS CLI) to perform these steps.

Using the Amazon VPC console

1.    Open the Amazon VPC console.

2.    Choose Endpoint services.

3.    Enter the Network Load Balancer's ARN in the Filter field to search for endpoint services.

4.    Select the Endpoint connections tab to determine which endpoint connections are attached to your endpoint service.

5.    For all the connections that aren't in the Rejected state, choose Actions, Reject endpoint connection request.

6.    Select the Load Balancers tab.

7.    Choose Associate or Disassociate Load Balancers to disassociate your Network Load Balancer from the endpoint service.

8.    Uncheck the Network Load Balancer's name under Available Load Balancers and then select Save changes.

Note: If there are no other load balancers associated with this endpoint service, then you receive the error message Must select at least one Load Balancer. If you receive this error, delete the VPC endpoint service to remove the association.

9.    To delete the Network Load Balancer, see Delete a Network Load Balancer.

Using the AWS CLI

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

1.    Run the describe-vpc-endpoint-service-configurations command to describe the VPC endpoint service configurations:

Note: In the following example command, replace us-east-1 with the Region where your Network Load Balancer is located.

aws ec2 describe-vpc-endpoint-service-configurations --region us-east-1 | grep -B 1 -A 3 /net/

The preceding command filters the Network Load Balancer ARN and the associated endpoint service name in the Region. In the command output, search for the Network Load Balancer's ARN (or use a more specific filter in grep). If you find a match, then the Network Load Balancer is associated with VPC endpoint services. Note the service ID of the VPC endpoint service.

Example output

$ aws ec2 describe-vpc-endpoint-service-configurations --region us-east-1 | grep -B 1 -A 3 /net/
            "NetworkLoadBalancerArns": [
                "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/NLB-Test/ca76ff83bdfc24c6"
            ],
            "ServiceName": "com.amazonaws.vpce.us-east-1.vpce-svc-1234abc1234abc123",
            "Tags": [

2.    Reject the endpoint connections on the service using the reject-vpc-endpoint-connections command, as shown in the following example:

aws ec2 reject-vpc-endpoint-connections --service-id vpce-svc-1234abc1234abc123 --vpc-endpoint-ids vpce-1234abc1234abc123

3 Run the modify-vpc-endpoint-service-configuration command to disassociate the Network Load Balancer from the VPC endpoint service, as shown in the following example:

aws ec2 modify-vpc-endpoint-service-configuration --service-id vpce-svc-1234abc1234abc123 --remove-network-load-balancer-arns arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/NLB-Test/ca76ff83bdfc24c
  1. Run the delete-load-balancer to delete the Network Load Balancer.

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago