从 YAML 配置文件部署时,如何配置 Google 计算实例以允许 http 流量?

How do I configure a Google Compute Instance to allow http traffic when deploying from a YAML config file?

如标题所示,我正在尝试在 GCP 中配置部署。目前,所有部署都由一个 Compute 实例组成,尽管我在尝试将 http-server 和 https-server 标记添加到配置文件时遇到了问题。无需尝试添加标签即可很好地创建实例。这是我的 yaml 文件的顶部:

resources:
- type: compute.v1.instance
  name: [redacted]
  properties:
    zone: europe-west1-b
    # Allow http and https traffic
    tags:
    - http-server
    - https-server
    machineType: https://www.googleapis.com/compute/v1/projects/[redacted]/zones/europe-west1-b/machineTypes/f1-micro
.......etc

我得到的错误是:

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1548860751491-580ae3ee63331-467fd040-1f00fce0]: errors:
- code: CONDITION_NOT_MET
  location: /deployments/[redacted]/resources/[redacted]>$.properties
  message: '"/tags": domain: validation; keyword: type; message: instance does not
    match any allowed primitive type; allowed: ["object"]; found: "array"'

这是我第一次尝试编写 yaml 配置文件,因此可能存在一些简单的上下文问题。

我自己解决了:

tags:
  items:
  - http-server
  - https-server

添加标签以计算实例属性:

tags:
      items: ["http-server"]

添加新资源(在计算实例网络接口下):

- type: compute.v1.firewall
  name: default-allow-http
  properties:
    targetTags: ["http-server"]
    sourceRanges: ["0.0.0.0/0"]
    allowed:
      - IPProtocol: TCP
        ports: ["80"]