google-cloud-platform - 错误: instance type null does not match any allowed primitive type

标签 google-cloud-platform terraform terraform-provider-gcp google-deployment-manager

我正在尝试使用以下 yaml 文件 (terraform) 在 gcp 中创建计算实例

resources :
- type : compute.v1.instance
  name: quickstart-deployment-vm
  properties:
       zone: us-central1-f
       machineType: f1-micro
       disks:
                 - deviceName: boot
                   type: PERSISTENT
                   boot: true
                   autoDelete: true
                   initializeParams:
                             sourceImage: debian-cloud/debian-9
       networkInterfaces:
                 - network:
                   accessConfigs:
                     - name: ExternalNAT
                       type: ONE_TO_ONE_NAT

但收到以下错误

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1673778262629-5f24adec6dda7-44a3a3ab-e5cbf301]: errors:
- code: CONDITION_NOT_MET
  location: /deployments/my-deployment/resources/quickstart-deployment-vm->$.properties
  message: |
    error: instance type (null) does not match any allowed primitive type (allowed: ["string"])
        level: "error"
        schema: {"loadingURI":"#","pointer":"/schemas/NetworkInterface/properties/network"}
        instance: {"pointer":"/networkInterfaces/0/network"}
        domain: "validation"
        keyword: "type"
        found: "null"
        expected: ["string"]

请帮我解决这个错误

最佳答案

错误表明 network 键需要 string 类型值,但存在一个 null 值。这是准确的,因为该 key 没有值。我们可以通过以下方法解决此问题:

networkInterfaces:
- network: default
  accessConfigs:
  - name: ExternalNAT
    type: ONE_TO_ONE_NAT

关于google-cloud-platform - 错误: instance type null does not match any allowed primitive type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75124458/

相关文章:

google-cloud-platform - JanusGraph 大规模数据摄取

google-app-engine - 将图像和结构化数据存储在一起(Google Cloud Platform)

terraform - 如何在磁盘附件后应用 remote-exec 配置程序?

terraform - 创建具有版本控制的 GCS 存储桶

docker - 使用 Gunicorn 工作器管理器在 Docker 容器中运行 PyTorch 多处理

google-app-engine - 带有 SignedURL 的 CORS

json - 如何使用 terraform 动态创建具有可变数量资源 block 的 AWS IAM 策略文档?

amazon-web-services - 条件表达式在 aws_security_group 资源导出 block terraform 中不起作用

google-cloud-platform - Terraform:无法使用生成的 SSH key 在计算引擎 VM 上远程执行

删除数据库后,Terraform 尝试读取 SQL 用户