Creates a new VPC endpoint for the specified service and associates it with the specified route tables. :param vpc_id: The ID of the VPC to create the endpoint in. :param service_name: The name of the service to create the endpoint for. :param route_table_ids: A lis
(
self, vpc_id: str, service_name: str, route_table_ids: list[str]
)
| 85 | |
| 86 | # snippet-start:[python.example_code.ec2.CreateVpcEndpoint] |
| 87 | def create_vpc_endpoint( |
| 88 | self, vpc_id: str, service_name: str, route_table_ids: list[str] |
| 89 | ) -> Dict[str, Any]: |
| 90 | """ |
| 91 | Creates a new VPC endpoint for the specified service and associates it with the specified route tables. |
| 92 | |
| 93 | :param vpc_id: The ID of the VPC to create the endpoint in. |
| 94 | :param service_name: The name of the service to create the endpoint for. |
| 95 | :param route_table_ids: A list of IDs of the route tables to associate with the endpoint. |
| 96 | :return: A dictionary representing the newly created VPC endpoint. |
| 97 | """ |
| 98 | try: |
| 99 | response = self.ec2_client.create_vpc_endpoint( |
| 100 | VpcId=vpc_id, |
| 101 | ServiceName=service_name, |
| 102 | RouteTableIds=route_table_ids, |
| 103 | ) |
| 104 | return response["VpcEndpoint"] |
| 105 | except ClientError as err: |
| 106 | logger.error( |
| 107 | "Couldn't create VPC endpoint for service %s. Here's why: %s: %s", |
| 108 | service_name, |
| 109 | err.response["Error"]["Code"], |
| 110 | err.response["Error"]["Message"], |
| 111 | ) |
| 112 | raise |
| 113 | |
| 114 | # snippet-end:[python.example_code.ec2.CreateVpcEndpoint] |
| 115 |
no outgoing calls