【问题标题】:GCP endpoints and needed portsGCP 端点和所需端口
【发布时间】:2020-09-30 20:50:45
【问题描述】:

我正在使用 google gcp go SDK(例如 https://godoc.org/cloud.google.com/go/kms/apiv1#NewKeyManagementClient 来初始化 KMS 客户端)。出于安全考虑,我需要确切知道 google SDK 将联系哪些端点和端口以与 GCP 通信。

我在官方文档中找不到任何内容(仅通过 cloudVPC 为本地设置,我认为这不是我需要的)。

如何找到云 GCP SDK 与 GCP 平台通信所需的端点和端口?

【问题讨论】:

    标签: go networking google-cloud-platform


    【解决方案1】:

    端点当前是cloudkms.googleapis.com:443,除非明确配置。没有记录的事实意味着它可能会随着时间的推移而更改,恕不另行通知(尽管如果确实发生更改,也不太可能不通知)。

    func defaultKeyManagementClientOptions() []option.ClientOption {
        return []option.ClientOption{
            option.WithEndpoint("cloudkms.googleapis.com:443"),
            option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
            option.WithScopes(DefaultAuthScopes()...),
            option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
                grpc.MaxCallRecvMsgSize(math.MaxInt32))),
        }
    }
    

    https://github.com/googleapis/google-cloud-go/blob/af69f73/kms/apiv1/key_management_client.go#L66-L74

    如需最新信息,请查询发现服务https://www.googleapis.com/discovery/v1/apis/cloudkms/v1/rest

    $ curl -s https://www.googleapis.com/discovery/v1/apis/cloudkms/v1/rest | jq -r .rootUrl
    https://cloudkms.googleapis.com/
    

    【讨论】:

    • 但是,在联系 KMS 服务之前,您需要一个通过调用此端点 https://oauth2.googleapis.com/token 生成的访问令牌。我建议您在端口 443 上打开到 *.googleapis.com 的出口流量,以避免任何副作用或 API 行为的变化。
    猜你喜欢
    • 1970-01-01
    • 2020-08-17
    • 1970-01-01
    • 2017-01-10
    • 2021-01-04
    • 2020-02-05
    • 2019-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多