部署管理器物联网核心类型提供程序创建

时间:2017-12-08 14:18:49

标签: google-cloud-platform gcloud gcp google-deployment-manager

我尝试创建部署,该部署使用部署管理器类型提供程序用于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

我执行以下步骤:

  1. 通过gcloud进行身份验证。

    $ gcloud config set project myproject
    $ gcloud config set account my_user@gmail.com
    $ gcloud auth application-default login
    
  2. 为物联网核心注册新的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
    
  3. 创建使用iotcore类型提供程序的新部署(请参阅config.yaml文件)。

    $ gcloud deployment-manager deployments create test --config config.yaml
    
  4. 在此命令之后,我遇到上述问题UNAUTHENTICATED

    现有的文档也不是很全面的例子。我遵循了Deployment Manager中的以下手册:

    此外,我尝试调整IoT Core更复杂的示例,该示例使用$.concat("Bearer ", $.googleOauth2AccessToken()),但问题相同。

    如果有人帮助我完成这个简单的示例工作或指出错过的步骤或问题,那就太棒了。

    非常感谢!

1 个答案:

答案 0 :(得分:0)

我似乎需要使用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

上有一个正在运行的例子