我正在使用Google gcp go SDK(例如https://godoc.org/cloud.google.com/go/kms/apiv1#NewKeyManagementClient初始化KMS客户端)。为了安全起见,我需要确切知道Google SDK将与GCP进行通信的端点和端口。
我在官方文档中找不到任何内容(仅通过cloudVPC进行本地设置,我认为这不是我所需要的)。
如何找到云GCP SDK与GCP平台进行通信所需的端点和端口?
最佳答案
端点当前为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/
关于go - GCP端点和所需的端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64135955/