我试图创建使用 GCP IoT Core 的部署管理器类型提供程序的部署,但不断遇到问题:
$ gcloud deployment-manager deployments create test --config config.yaml
The fingerprint of the deployment is 83pRfPUlfBoXQp6VhhpQ7w==
Waiting for create [operation-1512573397953-55fad7014e9e8-f4ceacbe-eb8f2b03]...failed.
ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1512573397953-55fad7014e9e8-f4ceacbe-eb8f2b03]: errors:
- code: RESOURCE_ERROR
location: /deployments/test/resources/MyRegistry
message: '{"ResourceType":"myproject/iotcore:projects.locations.registries","ResourceErrorCode":"401","ResourceErrorMessage":{"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.","status":"UNAUTHENTICATED","statusMessage":"Unauthorized","requestPath":"https://cloudiot.googleapis.com/v1/projects/myproject/locations/us-central1/registries","httpMethod":"POST"}}'
以下是内容config.yaml
:
resources:
- name: MyRegistry
type: myproject/iotcore:projects.locations.registries
properties:
parent: projects/myproject/locations/us-central1
id: myregistry
以下是内容cred.yaml
:
credential:
basicAuth:
user: my_user@gmail.com
password: my_password
我执行以下步骤:
通过身份验证
gcloud
。$ gcloud config set project myproject $ gcloud config set account my_user@gmail.com $ gcloud auth application-default login
为 IoT Core 注册新的 Deployment Manager 类型提供程序。
$ gcloud beta deployment-manager type-providers create iotcore --descriptor-url=https://content.googleapis.com/discovery/v1/apis/cloudiot/v1/rest --api-options-file ./cred.yaml
创建使用
iotcore
Type Provider 的新部署(参见config.yaml
文件)。$ gcloud deployment-manager deployments create test --config config.yaml
在此命令之后,我得到上述问题UNAUTHENTICATED
。
此外,现有文档的示例也不是很全面。我遵循了 Deployment Manager 的以下手册:
此外,我尝试针对 IoT Core 更复杂的示例进行调整,该示例使用$.concat("Bearer ", $.googleOauth2AccessToken())
但存在相同的问题。
如果有人帮助我完成这个简单的示例工作或指出遗漏的步骤或问题,那就太好了。
非常感谢!