管理专用连接端点:AWS¶
本主题提供有关如何管理专用连接端点的信息,以便与 AWS 的出站专用连接配合使用。
提供专用连接端点¶
备注
AWS doesn't support cross-region VPC interface endpoints for the Amazon S3 service. Therefore, cross-region PrivateLink isn't supported for outbound connectivity to external stages and volumes that use the Amazon S3 service.
Cross-region support for AWS PrivateLink isn't available in government regions or in the People's Republic of China.
You can use the SYSTEM$PROVISION_PRIVATELINK_ENDPOINT system function to create a private connectivity endpoint by specifying the service or resource, and the host name. You must use the ACCOUNTADMIN role when you use this system function.
备注
If you use private connectivity for an external stage or external volume, you must use the wildcard character * when you specify
the host name. Using the wildcard doesn't mean that all Amazon S3 buckets are accessed over a private connection. Only buckets referenced
by a Snowflake object that is enabled for private connectivity --- that is, the external stage or external volume --- can be accessed
through the VPC endpoint.
For example, to create a PrivateLink endpoint that connects to Amazon S3, execute the following SQL statement to configure an endpoint for
us-west-2:
SELECT SYSTEM$PROVISION_PRIVATELINK_ENDPOINT(
'com.amazonaws.us-west-2.s3',
'*.s3.us-west-2.amazonaws.com'
);
备注
When you configure an endpoint for Amazon S3 or another platform as a service (PaaS), such as KMS, that service must be in the same region as your Snowflake account.
SYSTEM$PROVISION_PRIVATELINK_ENDPOINT 函数接受提供商服务名称和主机名作为其实参。您可以通过使用 AWS 命令行的 describe-vpc-endpoint-services 子命令获取这些值。如 AWS 文档 (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-vpc-endpoint-services.html) 中所述,此 AWS 子命令返回一个 JSON 对象,具有 ServiceName 字段和 PrivateDnsName 字段。使用以下表来确定 SYSTEM$PROVISION_PRIVATELINK_ENDPOINT 函数应使用哪些值:
SYSTEM$PROVISION_PRIVATELINK_ENDPOINT 实参 |
|
|---|---|
|
|
|
If you use private connectivity for external stages or external volumes, you must use the value with a wildcard. |
You can create a private connectivity endpoint to a VPC endpoint service in an AWS region that is different from your Snowflake region. If you do, ensure that the VPC endpoint service supports the Snowflake region.
重要
Before you specify the provider_service_name as an argument for the SYSTEM$PROVISION_PRIVATELINK_ENDPOINT function, refer to the
Cross-Region Connectivity Pricing section on the AWS PrivateLink pricing (https://aws.amazon.com/privatelink/pricing) page to determine
the appropriate region.
If the target service is a VPC endpoint service (https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html), the endpoint service must allow Snowflake
to connect to it. Before you create an endpoint, add the value of privatelink-account-principal
from the output of SYSTEM$GET_PRIVATELINK_CONFIG as an allowed principal (https://docs.aws.amazon.com/vpc/latest/privatelink/configure-endpoint-service.html#add-remove-permissions) of the VPC endpoint service.
The following SQL statement configures an endpoint to a VPC endpoint service:
SELECT SYSTEM$PROVISION_PRIVATELINK_ENDPOINT(
'com.amazonaws.vpce.us-west-2.vpce-svc-012345678910f1234',
'my.onprem.storage.com'
);
备注
In this example, the service might be in different region from your Snowflake account.
在您创建端点后,使用该端点之前会有一个延迟。有关检查已创建端点状态的信息,请参阅 SYSTEM$GET_PRIVATELINK_ENDPOINTS_INFO。
设置与无法直接访问的端点的连接¶
并非所有服务都允许 Snowflake 通过接口端点直接连接到特定实例。在这些情况下,您可以改为通过 设置代理并将该服务公开为 VPC 端点服务 来启用对服务的访问权限。
如需专门的 Amazon RDS 引导教程,请参阅博客文章 使用 Snowflake 的专用连接功能连接至 Amazon RDS (link removed)。
了解是否可以直接访问某项服务¶
如果满足以下条件之一,Snowflake 通常可以通过专用连接直接访问 AWS 服务:
服务的 DNS 名称 - 其
PrivateDnsName值来自 AWS DescribeVpcEndpointServices (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpointServices.html) 的输出 - 前缀为通配符。如果服务的 DNS 名称以通配符
*开头,则 AWS 可能支持直接访问该服务上的各项资源。DNS 名称通常采用以下形式:*.<service>.<region>.amazonaws.com
该服务完全属于数据平面服务。AWS Bedrock Runtime (https://docs.aws.amazon.com/bedrock/latest/APIReference/API_Operations_Amazon_Bedrock_Runtime.html) 就是其中一个示例。
要了解有关给定服务的此类信息,请参阅 AWS 文档和博客文章。
无法直接访问时访问服务¶
当无法通过接口端点直接访问某项服务时,您可以通过设置代理并将该服务公开为 VPC 端点服务来启用对该服务的访问。
此类服务的示例包括:
位于
ec2.us-west-2.amazonaws.com的 Amazon EC2 实例位于
rds.us-west-2.amazonaws.com的 Amazon Relational Database Service (RDS) 服务器
将 AWS 设置为通过代理进行访问¶
要通过代理公开服务实例,您需要在 AWS 上设置虚拟私有云 (VPC) 和负载均衡器,然后使用 AWS 端点服务的服务名称和负载均衡器 DNS 器名称创建 Snowflake 专用链接端点。
下面介绍基本步骤:
在 AWS 上创建 `虚拟私有云 (VPC)<https://docs.aws.amazon.com/vpc/latest/userguide/create-vpc.html>`_,其子网跨越三个不同的可用区。
为您的资源选择初始可用区(例如 az1 和 az2);在某些区域,Snowflake 可能不支持更新的 AZs。确保在相同的可用区中创建端点和其他资源,以避免跨区域流量。
在您要访问的服务实例的网络设置中,确保该实例位于您创建的 VPC 中。
创建包含要访问的服务实例的 目标组 (https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-target-group.html)。
创建 网络负载均衡器 (https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-network-load-balancer.html),将流量转发到您创建的目标组。
使用您创建的网络负载均衡器创建 端点服务 (https://docs.aws.amazon.com/vpc/latest/privatelink/configure-endpoint-service.html)。
记录端点服务名称
endpoint_service_name,以便在设置 Snowflake 以访问该服务时使用。在 Snowflake 中,执行以下查询以检索 Snowflake 账户主体,并允许创建端点:
SELECT key, value FROM TABLE(FLATTEN(INPUT => PARSE_JSON(SYSTEM$GET_PRIVATELINK_CONFIG())));
在查询结果中,找到
privatelink-account-principal密钥并记下其值。在 AWS 中,对于您创建的端点服务,更新 Allow principals 部分,以添加一个 ARN 为 Snowflake
privatelink-account-principal密钥值的主体。在 Snowflake 中,为您创建的 AWS 端点服务创建专用端点。
执行 SYSTEM$PROVISION_PRIVATELINK_ENDPOINT 函数时,使用以下值作为实参:
SYSTEM$PROVISION_PRIVATELINK_ENDPOINT 实参
来自 AWS 配置的值
provider_service_nameAWS 端点 Service name:
endpoint_service_name值,来自端点服务的详细信息部分。host_name来自您创建的网络负载均衡器的 DNS Name。
在 AWS 批准 PrivateLink 连接:
导航到您创建的端点服务的端点连接。
选择处于待处理状态的相关端点连接。
点击 Accept Endpoint Connection Request。
通过运行以下查询来验证端点状态。
确保端点状态从
pendingAcceptance更改为available。SELECT SYSTEM$GET_PRIVATELINK_ENDPOINTS_INFO();
Change the host name of a private connectivity endpoint¶
You can change only the host name of a previously provisioned, private connectivity endpoint without changing its network resource. Changing the host name for an endpoint tells Snowflake that this endpoint now connects to the same service by using a different host name. To change the host name, call the SYSTEM$SET_PRIVATELINK_ENDPOINT_HOSTNAME system function.
移除服务的一个专用连接端点¶
您可以使用 SYSTEM$DEPROVISION_PRIVATELINK_ENDPOINT 系统函数通过指定服务或资源来移除专用连接端点。
在端点被移除后,端点会被放入队列中,7 天后将被删除。
在使用此系统函数时,您需要使用 ACCOUNTADMIN 角色。
例如,要移除一个可以从外部访问 Amazon S3 的 PrivateLink,请执行以下 SQL 语句:
SELECT SYSTEM$DEPROVISION_PRIVATELINK_ENDPOINT('com.amazonaws.us-west-2.s3');
恢复服务的一个专用连接端点¶
您可以使用 SYSTEM$RESTORE_PRIVATELINK_ENDPOINT 系统函数通过指定服务或资源来恢复仍在删除队列中的已移除专用连接端点。如果在删除队列中找不到端点,则无法恢复该端点。
在使用此系统函数时,您需要使用 ACCOUNTADMIN 角色。
例如,要恢复一个可以从外部访问 Amazon S3 的 PrivateLink,请执行以下 SQL 语句:
SELECT SYSTEM$RESTORE_PRIVATELINK_ENDPOINT('com.amazonaws.us-west-2.s3');
列出服务的所有专用连接端点¶
您可以使用 SYSTEM$GET_PRIVATELINK_ENDPOINTS_INFO 系统函数列出您账户中的所有专用连接端点及其信息。
在使用此系统函数时,您需要使用 ACCOUNTADMIN 角色。
例如,要列出所有 AWS PrivateLink 端点和 AWS 服务,请执行以下 SQL 语句:
SELECT SYSTEM$GET_PRIVATELINK_ENDPOINTS_INFO();
[
{
"provider_service_name": "com.amazonaws.us-west-2.s3",
"snowflake_endpoint_name": "vpce-123456789012abcdea",
"endpoint_state": "CREATED",
"host": "*.s3.us-west-2.amazonaws.com",
"status": "Available"
},
...
]
有关函数返回的 JSON 对象字段的描述,请参阅 返回。
备注
您还可以查询 ACCOUNT_USAGE 架构中的 OUTBOUND_PRIVATELINK_ENDPOINTS 视图,以列出您账户中的专用端点。