Skip to content

create_vpc_endpoint

create_vpc_endpoint(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    vpc_endpoint_type: Optional[VpcEndpointType] = None,
    vpc_id: Optional[VpcId] = None,
    service_name: Optional[String] = None,
    policy_document: Optional[String] = None,
    route_table_ids: Optional[VpcEndpointRouteTableIdList] = None,
    subnet_ids: Optional[VpcEndpointSubnetIdList] = None,
    security_group_ids: Optional[VpcEndpointSecurityGroupIdList] = None,
    ip_address_type: Optional[IpAddressType] = None,
    dns_options: Optional[DnsOptionsSpecification] = None,
    client_token: Optional[String] = None,
    private_dns_enabled: Optional[Boolean] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    subnet_configurations: Optional[SubnetConfigurationsList] = None,
    service_network_arn: Optional[ServiceNetworkArn] = None,
    resource_configuration_arn: Optional[ResourceConfigurationArn] = None,
    service_region: Optional[String] = None,
) -> CreateVpcEndpointResult

Creates a VPC endpoint. A VPC endpoint provides a private connection between the specified VPC and the specified endpoint service. You can use an endpoint service provided by Amazon Web Services, an Amazon Web Services Marketplace Partner, or another Amazon Web Services account. For more information, see the Amazon Web Services PrivateLink User Guide.

Parameters:

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • vpc_endpoint_type (Optional[VpcEndpointType], default: None ) –

    The type of endpoint.

    For more information about the types of VPC endpoints, see VPC endpoints in the Amazon Web Services PrivateLink User Guide.

    Default: Gateway

  • vpc_id (Optional[VpcId], default: None ) –

    The ID of the VPC.

  • service_name (Optional[String], default: None ) –

    The name of the endpoint service.

  • policy_document (Optional[String], default: None ) –

    (Interface and gateway endpoints) A policy to attach to the endpoint that controls access to the service. The policy must be in valid JSON format. If this parameter is not specified, we attach a default policy that allows full access to the service.

  • route_table_ids (Optional[VpcEndpointRouteTableIdList], default: None ) –

    (Gateway endpoint) The route table IDs.

  • subnet_ids (Optional[VpcEndpointSubnetIdList], default: None ) –

    (Interface, Gateway Load Balancer endpoints, Resource, ServiceNetwork, and Tunnel endpoints only) The IDs of the subnets in which to create endpoint network interfaces. For a Gateway Load Balancer endpoint, you can specify only one subnet. For a Tunnel endpoint, the subnets must be in the Availability Zones of the resource gateway associated with the shared resource configuration. An endpoint network interface is created only in an Availability Zone that the resource gateway is also in.

  • security_group_ids (Optional[VpcEndpointSecurityGroupIdList], default: None ) –

    (Interface, Resource, ServiceNetwork, and Tunnel endpoints only) The IDs of the security groups to associate with the endpoint network interfaces. If this parameter is not specified, we use the default security group for the VPC.

  • ip_address_type (Optional[IpAddressType], default: None ) –

    The IP address type for the endpoint.

  • dns_options (Optional[DnsOptionsSpecification], default: None ) –

    The DNS options for the endpoint.

  • client_token (Optional[String], default: None ) –

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.

  • private_dns_enabled (Optional[Boolean], default: None ) –

    (Interface endpoint) Indicates whether to associate a private hosted zone with the specified VPC. The private hosted zone contains a record set for the default public DNS name for the service for the Region (for example, kinesis.us-east-1.amazonaws.com), which resolves to the private IP addresses of the endpoint network interfaces in the VPC. This enables you to make requests to the default public DNS name for the service instead of the public DNS names that are automatically generated by the VPC endpoint service.

    To use a private hosted zone, you must set the following VPC attributes to true: enableDnsHostnames and enableDnsSupport. Use ModifyVpcAttribute to set the VPC attributes.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to associate with the endpoint.

  • subnet_configurations (Optional[SubnetConfigurationsList], default: None ) –

    The subnet configurations for the endpoint.

  • service_network_arn (Optional[ServiceNetworkArn], default: None ) –

    The Amazon Resource Name (ARN) of a service network that will be associated with the VPC endpoint of type service-network.

  • resource_configuration_arn (Optional[ResourceConfigurationArn], default: None ) –

    (Resource and Tunnel endpoints only) The Amazon Resource Name (ARN) of a resource configuration associated with the VPC endpoint. The type of resource configuration depends on the endpoint type:

    • For a Resource endpoint, you can specify a resource configuration that is of type SINGLE, GROUP, or ARN. To reach a resource that belongs to a group, specify the parent GROUP resource configuration.

    • For a Tunnel endpoint, you can specify a resource configuration that is of type CIDR.

    For more information about the types of resource configurations, see Types of resource configurations in the Amazon Web Services PrivateLink User Guide.

    This request fails if a VPC endpoint owned by a different Amazon Web Services account already exists on a resource gateway that is enabled for ResourceGatewayCharges payer responsibility.

  • service_region (Optional[String], default: None ) –

    The Region where the service is hosted. The default is the current Region.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def create_vpc_endpoint(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    vpc_endpoint_type: Optional[
        "capo_ec2.types.vpc_endpoint_type.VpcEndpointType"
    ] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
    service_name: Optional["capo_ec2.types.string.String"] = None,
    policy_document: Optional["capo_ec2.types.string.String"] = None,
    route_table_ids: Optional[
        "capo_ec2.types.vpc_endpoint_route_table_id_list.VpcEndpointRouteTableIdList"
    ] = None,
    subnet_ids: Optional[
        "capo_ec2.types.vpc_endpoint_subnet_id_list.VpcEndpointSubnetIdList"
    ] = None,
    security_group_ids: Optional[
        "capo_ec2.types.vpc_endpoint_security_group_id_list.VpcEndpointSecurityGroupIdList"
    ] = None,
    ip_address_type: Optional[
        "capo_ec2.types.ip_address_type.IpAddressType"
    ] = None,
    dns_options: Optional[
        "capo_ec2.types.dns_options_specification.DnsOptionsSpecification"
    ] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    private_dns_enabled: Optional["capo_ec2.types.boolean.Boolean"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    subnet_configurations: Optional[
        "capo_ec2.types.subnet_configurations_list.SubnetConfigurationsList"
    ] = None,
    service_network_arn: Optional[
        "capo_ec2.types.service_network_arn.ServiceNetworkArn"
    ] = None,
    resource_configuration_arn: Optional[
        "capo_ec2.types.resource_configuration_arn.ResourceConfigurationArn"
    ] = None,
    service_region: Optional["capo_ec2.types.string.String"] = None,
) -> "capo_ec2.types.create_vpc_endpoint_result.CreateVpcEndpointResult":
    """<p>Creates a VPC endpoint. A VPC endpoint provides a private connection between the specified VPC and the specified endpoint service. You can use an endpoint service provided by Amazon Web Services, an Amazon Web Services Marketplace Partner, or another Amazon Web Services account. For more information, see the <a href="https://docs.aws.amazon.com/vpc/latest/privatelink/">Amazon Web Services PrivateLink User Guide</a>.</p>

    Args:
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        vpc_endpoint_type: <p>The type of endpoint.</p> <p>For more information about the types of VPC endpoints, see <a href="https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html#concepts-vpc-endpoints">VPC endpoints</a> in the <i>Amazon Web Services PrivateLink User Guide</i>.</p> <p>Default: Gateway</p>
        vpc_id: <p>The ID of the VPC.</p>
        service_name: <p>The name of the endpoint service.</p>
        policy_document: <p>(Interface and gateway endpoints) A policy to attach to the endpoint that controls access to the service. The policy must be in valid JSON format. If this parameter is not specified, we attach a default policy that allows full access to the service.</p>
        route_table_ids: <p>(Gateway endpoint) The route table IDs.</p>
        subnet_ids: <p>(Interface, Gateway Load Balancer endpoints, Resource, ServiceNetwork, and Tunnel endpoints only) The IDs of the subnets in which to create endpoint network interfaces. For a Gateway Load Balancer endpoint, you can specify only one subnet. For a <code>Tunnel</code> endpoint, the subnets must be in the Availability Zones of the resource gateway associated with the shared resource configuration. An endpoint network interface is created only in an Availability Zone that the resource gateway is also in.</p>
        security_group_ids: <p>(Interface, Resource, ServiceNetwork, and Tunnel endpoints only) The IDs of the security groups to associate with the endpoint network interfaces. If this parameter is not specified, we use the default security group for the VPC.</p>
        ip_address_type: <p>The IP address type for the endpoint.</p>
        dns_options: <p>The DNS options for the endpoint.</p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html">How to ensure idempotency</a>.</p>
        private_dns_enabled: <p>(Interface endpoint) Indicates whether to associate a private hosted zone with the specified VPC. The private hosted zone contains a record set for the default public DNS name for the service for the Region (for example, <code>kinesis.us-east-1.amazonaws.com</code>), which resolves to the private IP addresses of the endpoint network interfaces in the VPC. This enables you to make requests to the default public DNS name for the service instead of the public DNS names that are automatically generated by the VPC endpoint service.</p> <p>To use a private hosted zone, you must set the following VPC attributes to <code>true</code>: <code>enableDnsHostnames</code> and <code>enableDnsSupport</code>. Use <a>ModifyVpcAttribute</a> to set the VPC attributes.</p>
        tag_specifications: <p>The tags to associate with the endpoint.</p>
        subnet_configurations: <p>The subnet configurations for the endpoint.</p>
        service_network_arn: <p>The Amazon Resource Name (ARN) of a service network that will be associated with the VPC endpoint of type service-network.</p>
        resource_configuration_arn: <p>(Resource and Tunnel endpoints only) The Amazon Resource Name (ARN) of a resource configuration associated with the VPC endpoint. The type of resource configuration depends on the endpoint type:</p> <ul> <li> <p>For a Resource endpoint, you can specify a resource configuration that is of type <code>SINGLE</code>, <code>GROUP</code>, or <code>ARN</code>. To reach a resource that belongs to a group, specify the parent <code>GROUP</code> resource configuration.</p> </li> <li> <p>For a Tunnel endpoint, you can specify a resource configuration that is of type <code>CIDR</code>.</p> </li> </ul> <p>For more information about the types of resource configurations, see <a href="https://docs.aws.amazon.com/vpc/latest/privatelink/resource-configuration.html">Types of resource configurations</a> in the <i>Amazon Web Services PrivateLink User Guide</i>.</p> <p>This request fails if a VPC endpoint owned by a different Amazon Web Services account already exists on a resource gateway that is enabled for <code>ResourceGatewayCharges</code> payer responsibility.</p>
        service_region: <p>The Region where the service is hosted. The default is the current Region.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_vpc_endpoint_request.CreateVpcEndpointRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_vpc_endpoint_result.CreateVpcEndpointResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_vpc_endpoint

        output, http_response = (
            capo_ec2._operations.amazon_ec2.create_vpc_endpoint.create_vpc_endpoint(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateVpcEndpoint")
    )
    input_: capo_ec2.types.create_vpc_endpoint_request.CreateVpcEndpointRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if vpc_endpoint_type is not None:
        input_["vpc_endpoint_type"] = vpc_endpoint_type
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if service_name is not None:
        input_["service_name"] = service_name
    if policy_document is not None:
        input_["policy_document"] = policy_document
    if route_table_ids is not None:
        input_["route_table_ids"] = route_table_ids
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type
    if dns_options is not None:
        input_["dns_options"] = dns_options
    if client_token is not None:
        input_["client_token"] = client_token
    if private_dns_enabled is not None:
        input_["private_dns_enabled"] = private_dns_enabled
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if subnet_configurations is not None:
        input_["subnet_configurations"] = subnet_configurations
    if service_network_arn is not None:
        input_["service_network_arn"] = service_network_arn
    if resource_configuration_arn is not None:
        input_["resource_configuration_arn"] = resource_configuration_arn
    if service_region is not None:
        input_["service_region"] = service_region

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output