我尝试创建部署,该部署使用部署管理器类型提供程序用于GCP IoT核心但不断出现问题:
$ 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
为物联网核心注册新的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
类型提供程序的新部署(请参阅config.yaml
文件)。
$ gcloud deployment-manager deployments create test --config config.yaml
在此命令之后,我遇到上述问题UNAUTHENTICATED
。
现有的文档也不是很全面的例子。我遵循了Deployment Manager中的以下手册:
此外,我尝试调整IoT Core更复杂的示例,该示例使用$.concat("Bearer ", $.googleOauth2AccessToken())
,但问题相同。
如果有人帮助我完成这个简单的示例工作或指出错过的步骤或问题,那就太棒了。
非常感谢!
答案 0 :(得分:0)
我似乎需要使用action属性而不是type。尝试改变:
resources:
- name: MyRegistry
type: myproject/iotcore:projects.locations.registries
成:
resources:
- name: MyRegistry
action: myproject/iotcore:cloudiot.projects.locations.registries.create
上有一个正在运行的例子