【问题标题】:Add all DigitalOcean Droplet Instances to a Project in Terraform将所有 DigitalOcean Droplet 实例添加到 Terraform 中的项目中
【发布时间】:2021-04-08 02:57:00
【问题描述】:

我正在尝试循环来自 DigitalOcean Droplet 的所有实例,它有未知数量的实例要添加到 DigitalOcean 项目中。

类似下面的东西,但不知道怎么做

resource "digitalocean_droplet" "web" {
  count = var.droplet_count 
  name = "web-${var.name}-${var.region}-${count.index +1}"
  size   = "512mb"
  image  = "centos-7-x64"
  region = "nyc3"


}

resource "digitalocean_project_resources" "barfoo" {
  project = data.digitalocean_project.foo.id
  resources = [
     digitalocean_droplet.web.*.urn, # this part having issues with
     digitalocean_droplet.bastion.urn,
  ]
}

【问题讨论】:

    标签: terraform digital-ocean droplet


    【解决方案1】:

    resources - 与项目关联的资源的统一资源名称 (URN) 列表

    试试

    resources = flatten([digitalocean_droplet.web.*.urn, digitalocean_droplet.bastion.urn])
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-19
      • 2020-04-10
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      相关资源
      最近更新 更多