我试图创建部署,使用部署管理器类型提供程序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: [email protected]
password: my_password
我执行以下步骤:
gcloud
进行身份验证。
$ gcloud config set project myproject
$ gcloud config set account [email protected]
$ gcloud auth application-default login
$ 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中的以下手册:
此外,我试图调整物联网核心更复杂的例子,它使用$.concat("Bearer ", $.googleOauth2AccessToken())
但具有相同的问题。
如果有人帮助我完成这个简单的示例工作或指出错过的步骤或问题,那就太好了。
非常感谢!
我好像你需要使用action属性而不是type。尝试改变:
resources:
- name: MyRegistry
type: myproject/iotcore:projects.locations.registries
成:
resources:
- name: MyRegistry
action: myproject/iotcore:cloudiot.projects.locations.registries.create
我得到一个运行的例子:https://github.com/Ebolon/gcp-dm-cloudiot