Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use DeleteVpcEndpoints with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DeleteVpcEndpoints with an AWS SDK or CLI

The following code examples show how to use DeleteVpcEndpoints.

CLI
AWS CLI

To delete an endpoint

This example deletes endpoints vpce-aa22bb33 and vpce-1a2b3c4d. If the command is partially successful or unsuccessful, a list of unsuccessful items is returned. If the command succeeds, the returned list is empty.

Command:

aws ec2 delete-vpc-endpoints --vpc-endpoint-ids vpce-aa22bb33 vpce-1a2b3c4d

Output:

{ "Unsuccessful": [] }
PHP
SDK for PHP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/** * @param string $vpcEndpointId * @return void */ public function deleteVpcEndpoint(string $vpcEndpointId) { try { $this->ec2Client->deleteVpcEndpoints([ "VpcEndpointIds" => [$vpcEndpointId], ]); }catch (Ec2Exception $caught){ echo "There was a problem deleting the VPC Endpoint: {$caught->getAwsErrorMessage()}\n"; throw $caught; } }
Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

class VpcWrapper: """Encapsulates Amazon Elastic Compute Cloud (Amazon EC2) Amazon Virtual Private Cloud actions.""" def __init__(self, ec2_client: boto3.client): """ Initializes the VpcWrapper with an EC2 client. :param ec2_client: A Boto3 Amazon EC2 client. This client provides low-level access to AWS EC2 services. """ self.ec2_client = ec2_client @classmethod def from_client(cls) -> "VpcWrapper": """ Creates a VpcWrapper instance with a default EC2 client. :return: An instance of VpcWrapper initialized with the default EC2 client. """ ec2_client = boto3.client("ec2") return cls(ec2_client) def delete_vpc_endpoints(self, vpc_endpoint_ids: list[str]) -> None: """ Deletes the specified VPC endpoints. :param vpc_endpoint_ids: A list of IDs of the VPC endpoints to delete. """ try: self.ec2_client.delete_vpc_endpoints(VpcEndpointIds=vpc_endpoint_ids) except ClientError as err: logger.error( "Couldn't delete VPC endpoints %s. Here's why: %s: %s", vpc_endpoint_ids, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise
AWS CLI

To delete an endpoint

This example deletes endpoints vpce-aa22bb33 and vpce-1a2b3c4d. If the command is partially successful or unsuccessful, a list of unsuccessful items is returned. If the command succeeds, the returned list is empty.

Command:

aws ec2 delete-vpc-endpoints --vpc-endpoint-ids vpce-aa22bb33 vpce-1a2b3c4d

Output:

{ "Unsuccessful": [] }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.