使用Scaleway的Terraform不支持​​的属性错误

时间:2020-06-02 10:55:32

标签: terraform provisioning

运行terraform apply并键入'yes'后,我得到3次以下错误(因为我有3个空资源): Error: Unsupported attribute: This value does not have any attributes. 我检查了我的连接块中的每个条目,它似乎来自host属性。我相信错误是因为ips.address仅在服务器启动后生成,而terraform希望在BareMetal服务器部署之前为主机提供一个值。我在这里做错什么了吗,或者我使用了错误的值(我也尝试过ips.id),或者我需要为ips.address生成时创建某种输出,然后检查主机。我无法在ScaleWay的BareMetal设置中找到任何资源。这是我的instance_number = 3代码。

provider "scaleway" {
  access_key      = var.ACCESS_KEY
  secret_key      = var.SECRET_KEY
  organization_id = var.ORGANIZATION_ID
  zone            = "fr-par-2"
  region          = "fr-par"
}

resource "scaleway_account_ssh_key" "main" {
    name       = "main"
    public_key = file("~/.ssh/id_rsa.pub")
}


resource "scaleway_baremetal_server" "base" {
  count = var.instance_number
  name = "${var.env_name}-BareMetal-${count.index}"

  offer  = var.baremetal_type
  os = var.baremetal_image
  ssh_key_ids = [scaleway_account_ssh_key.main.id]

  tags = [ "BareMetal-${count.index}" ] 
}



resource "null_resource" "ssh" {
  count = var.instance_number
  connection {
    type = "ssh"
    private_key = file("~/.ssh/id_rsa")
    user = "root"
    password = ""
    host = scaleway_baremetal_server.base[count.index].ips.address
    port = 22
  }
  provisioner "remote-exec" {
    script = "provision/install_java_python.sh"

  }
}

0 个答案:

没有答案