检查 REST 目录配置¶
您可以使用以下场景来检查是否为 Iceberg REST 目录正确配置了授权和访问控制,以便 Snowflake 可以与目录服务器进行交互。
使用 SYSTEM$VERIFY_ CATALOG_ INTEGRATION¶
You can use the SYSTEM$VERIFY_CATALOG_INTEGRATION function to check your catalog integration configuration.
以下示例演示了系统函数如何捕获和报告目录集成配置不当的问题。
The following example statement creates a REST catalog integration using an invalid OAuth client secret (this runs without error):
Use the system function to verify the catalog integration, expecting failure:
Output:
检查 OAuth 的配置¶
按照以下步骤使用远程 REST 目录检查 OAuth 的配置。
第 1 步:检索访问令牌¶
Use a curl command to retrieve an access token from your catalog. The following example
requests an access token from Snowflake Open Catalog:
其中:
https://xx123xx.us-west-2.aws.snowflakecomputing.cn/polaris/api/catalog/v1/oauth/tokensis the endpoint for retrieving an OAuth token (getToken (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/open-api/rest-catalog-open-api.yaml#L132)).scopeis the same as the value that you specify forOAUTH_ALLOWED_SCOPESparameter when you create a catalog integration. For multiple scopes, use a space as a separator.my_client_idis the same client ID that you specify for theOAUTH_CLIENT_IDparameter when you create a catalog integration.my_client_secretis the same client secret that you specify for theOAUTH_CLIENT_SECRETparameter when you create a catalog integration.
返回值示例:
第 2 步:验证访问令牌权限¶
使用在上一步中检索到的访问令牌,验证自己是否拥有访问目录服务器的权限。
You can use a curl command to list the configuration settings for your catalog:
其中:
?warehouse=warehouseoptionally specifies the warehouse name to request from your catalog (if supported). For Snowflake Open Catalog, the warehouse name is your catalog name.ACCESS_TOKENis a variable that contains theaccess_tokenthat you retrieved in the previous step.
返回值示例:
第 3 步:从目录中加载表¶
You can also make a GET request to load a table. Snowflake uses the loadTable (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/open-api/rest-catalog-open-api.yaml#L616) operation to load table data from your REST catalog.
其中:
prefixoptionally specifies the prefix obtained from the previousgetConfigresponse.namespaceis the namespace of the table you want to retrieve. If the namespace is nested, use the%1Fseparator; for example,parentNamespace%1FchildNamespace.tableis the table name.
检查持有者令牌的配置
按照以下步骤在远程 REST 目录中检查使用持有者令牌的配置。
第 1 步:验证访问令牌权限¶
Use a curl command to verify that you have permission to access your catalog server:
其中:
https://xx123xx.us-west-2.aws.snowflakecomputing.cn/polaris/api/catalog/v1/oauth/tokensis the endpoint for retrieving an OAuth token (getToken (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/open-api/rest-catalog-open-api.yaml#L132)).?warehouse=warehouseoptionally specifies the warehouse name to request from your catalog (if supported).BEARER_TOKENis a variable that contains theaccess_tokenthat you retrieved in the previous step.
返回值示例:
第 2 步:从目录中加载表¶
You can also make a GET request to load a table. Snowflake uses the loadTable (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/open-api/rest-catalog-open-api.yaml#L616) operation to load table data from your REST catalog.
其中:
prefixoptionally specifies the prefix obtained from the previousgetConfigresponse.namespaceis the namespace of the table you want to retrieve. If the namespace is nested, use the%1Fseparator; for example,parentNamespace%1FchildNamespace.tableis the table name.
检查 SigV4 的配置¶
按照以下步骤通过 AWS 检查 SigV4 的配置。
第 1 步:将用户添加到 IAM 角色信任关系中¶
When you create a REST catalog integration for SigV4, Snowflake provisions an AWS IAM user for your Snowflake account. You add that Snowflake IAM user to the trust relationship for an IAM role with permission to access your API Gateway resources.
To test your configuration, you can assume the role as a user in your AWS account after you add your AWS user to the role’s trust policy document. To retrieve your current IAM user ARN, use the sts get-caller-identity (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sts/get-caller-identity.html) command for the AWS Command Line Interface (CLI) (https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) :
输出示例:
更新后的信任策略文档应包括 Snowflake 用户 ARN 和用户 ARN,具体如下:
For full instructions, see Update a role trust policy (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_update-role-trust-policy.html) in the AWS IAM documentation.
第 2 步:假设 IAM 角色以获取临时凭证¶
To get temporary security credentials for AWS, use the sts assume-role (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sts/assume-role.html) command for the AWS CLI.
其中:
my_role_arnis the Amazon Resource Name (ARN) of the IAM role that you’ve configured for Snowflake.session_nameis a string identifier of your choice for the assumed role session; for example,my_rest_session.
输出示例:
Note
If the assume-role command fails, it means that your current AWS user isn’t included in the role’s trust policy as
an allowed principal.
Similarly, if the Snowflake IAM user ARN isn’t included in your trust policy, Snowflake won’t be able to connect to your API Gateway resources. For more information, see Configure the trust relationship in IAM.
第 3 步:确认 IAM 角色是否拥有正确的权限¶
使用在上一步中检索到的临时凭证,验证 IAM 角色是否拥有调用 API Gateway APIs 的权限。
You can use a curl command to list the configuration settings for your catalog:
其中:
123xxxxxxx.execute-api.us-west-2.amazonaws.comis your API Gateway hostname.test_v2is the name of the stage that your API is deployed to.v1/configspecifies the getConfig (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/open-api/rest-catalog-open-api.yaml#L65) operation from the Iceberg catalog OpenAPI definition.?warehouse=warehouseoptionally specifies the warehouse name to request from your catalog (if supported).$AWS_ACCESS_KEY_IDis a variable that contains theAccessKeyIdthat you retrieved using thests assume-rolecommand.$AWS_SECRET_ACCESS_KEYis a variable that contains theSecretAccessKeythat you retrieved using thests assume-rolecommand.aws:amz:us-west-2:execute-apiis the signing name of the SigV4 protocol. For AWS Glue, useaws:amz:us-west-2:glueinstead.$AWS_SESSION_TOKENis a variable that contains theSessionTokenthat you retrieved using thests assume-rolecommand.
返回值示例:
You can also make a GET request to load a table. Snowflake uses the loadTable (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/open-api/rest-catalog-open-api.yaml#L616) operation to load table data from your REST catalog.
其中:
prefixoptionally specifies the prefix obtained from the previousgetConfigresponse.namespaceis the namespace of the table you want to retrieve. If the namespace is nested, use the%1Fseparator; for example,parentNamespace%1FchildNamespace.tableis the table name.
专用 API
For a private API, you can specify your VPC endpoint and private Amazon API Gateway hostname in the same curl commands.
例如:
其中:
https://vpce-xxxxxxxxxxxxxxxxxxxxxxxxxx.execute-api.us-west-2.vpce.amazonaws.com/...is the hostname of your VPC endpoint.abc1defgh2.execute-api.us-west-2.amazonaws.comis the hostname of your private API in Amazon API Gateway.