用于查询 SAP 的出站规则
查询 SAP 表时,您可能会看到以下错误:
VPC Service Controls: Request is prohibited by organization's policy. File: gs://example-bucket/path/to/file
发生这种情况是因为 BigQuery 必须读取托管表数据的 Cloud Storage 外部存储桶。如果您的边界限制了 storage.googleapis.com,您可能会收到 RESOURCES_NOT_IN_SAME_SERVICE_PERIMETER 错误,因为外部存储桶位于边界之外。如需解决此问题,请配置出站规则。
如需了解详情,请参阅资源不在同一边界内。
配置出站规则
如果您的 SAP 环境部署在Google Cloud上,则此配置适用。
如果您的项目使用 VPC Service Controls,并且边界限制了 storage.googleapis.com,则您必须配置出站规则,以允许 BigQuery 读取 SAP Cloud Storage 存储桶以进行表查询。
检查当前边界。
PERIMETER_NAME=accessPolicies/ACCESS_POLICY/servicePerimeters/PERIMETER gcloud access-context-manager perimeters describe ${PERIMETER_NAME}替换以下内容:
ACCESS_POLICY:您的访问权限政策。PERIMETER:您的服务边界。
如果响应包含以下内容,则边界会限制 Cloud Storage 存储桶读取:
resources: - projects/PROJECT_ID ... restrictedServices: - storage.googleapis.com导出当前出站流量规则,并附加一条规则以允许 Cloud Storage 存储桶读取。
PERIMETER_NAME=accessPolicies/ACCESS_POLICY/servicePerimeters/PERIMETER gcloud access-context-manager perimeters describe ${PERIMETER_NAME} \ --format="yaml(status.egressPolicies)" | sed '1,2d; s/^ //' > egress-policies.yaml替换以下内容:
ACCESS_POLICY:您的访问权限政策。PERIMETER:您的服务边界。
将此规则附加到
egress-policies.yaml,以便您读取边界外的 Cloud Storage 存储桶:- egressFrom: identityType: ANY_IDENTITY egressTo: operations: - methodSelectors: - method: google.storage.buckets.get - method: google.storage.objects.get - method: google.storage.objects.list serviceName: storage.googleapis.com resources: - '*'更新服务边界:
gcloud access-context-manager perimeters update ${PERIMETER_NAME} \ --set-egress-policies=egress-policies.yaml验证更新后的出站流量政策:
gcloud access-context-manager perimeters describe ${PERIMETER_NAME}
用于将数据发布到 SAP 的入站规则
SAP 需要查询 BigLake API 才能读取由 Lakehouse 管理的 Apache Iceberg 表。如果项目的边界限制了 biglake.googleapis.com 服务,则您的 VPC Service Controls 规则可能会阻止此操作。
如果您的项目强制执行 VPC Service Controls,并且应用于项目的边界限制了 biglake.googleapis.com 服务,则您必须配置入站流量规则,以允许 SAP 联合主账号访问 BigLake API。
配置入站规则
检查当前边界。
PERIMETER_NAME=accessPolicies/ACCESS_POLICY/servicePerimeters/PERIMETER gcloud access-context-manager perimeters describe ${PERIMETER_NAME}替换以下内容:
ACCESS_POLICY:您的访问权限政策。PERIMETER:您的服务边界。
如果响应包含以下内容,则服务边界可以限制 BigLake API:
resources: - projects/PROJECT_ID ... restrictedServices: - biglake.googleapis.com导出当前入站流量规则,并附加一条规则,以允许 SAP 联合主账号调用 Lakehouse API。
PERIMETER_NAME=accessPolicies/ACCESS_POLICY/servicePerimeters/PERIMETER gcloud access-context-manager perimeters describe ${PERIMETER_NAME} \ --format="yaml(status.ingressPolicies)" | sed '1,2d; s/^ //' > ingress-policies.yaml替换以下内容:
ACCESS_POLICY:您的访问权限政策。PERIMETER:您的服务边界。
为 SAP 联合主账号附加一条规则:
- ingressFrom: identities: - principal://iam.googleapis.com/projects/PROJECT_ID/locations/global/workloadIdentityPools/POOL_NAME/subject/SUBJECT sources: - accessLevel: '*' ingressTo: operations: - methodSelectors: - method: '*' serviceName: biglake.googleapis.com resources: - '*'替换以下内容:
PROJECT_ID:包含工作负载身份池的项目 ID。POOL_NAME:工作负载身份池的名称。SUBJECT:SAP 端颁发者为工作负载颁发的 UUID。
更新服务边界:
gcloud access-context-manager perimeters update ${PERIMETER_NAME} \ --set-ingress-policies=ingress-policies.yaml验证更新后的政策:
gcloud access-context-manager perimeters describe ${PERIMETER_NAME}