我正在尝试使用谷歌云控制台终端创建静态IP地址:
gcloud compute addresses create helloweb-ip --region us-central1
它返回:
Created [https://www.googleapis.com/compute/v1/projects/<project-name>-409407/regions/us-central1/addresses/helloweb-ip]
如果遵循,将返回以下 json:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadatas": {
"service": "compute.googleapis.com",
"method": "compute.v1.RegionAddressesService.Get"
}
}
]
}
}
不知道为什么这不起作用,但我不明白为什么它不起作用。据我所知,我已登录 gcloud 控制台应用程序。我一直在云控制台中的终端使用
gcloud
命令,而不是从任何本地配置的设备,因此我认为它已正确配置。
显然,从控制台打开 gcloud cli 后,您将直接尝试执行 gcloud 命令来创建静态 IP 地址。在运行本官方文档中提到的任何命令之前,需要满足一个先决条件。它以标题“开始之前”开头,在本节中他们提到了以下命令
gcloud init
首先,即使您已从控制台打开 gcloud cli,也需要执行此命令。它将帮助您验证您的谷歌云帐户并配置您要在其中部署资源的项目。