Terraform,在污点上收到“模块根没有资源”错误

Terraform,在污点上收到“模块根没有资源”错误

出现The module root has no resources污染错误。我正在尝试污染几个空资源。以下是的代码块null_resource.provision_first

resource "null_resource" "provision_first" {

    connection {

        user = "root"
        type = "ssh"
        private_key = "${file("./.ssh/prv_key")}"
        host = "${element(digitalocean_droplet.droplet.*.ipv4_address, count.index)}"
        timeout = "2m"
   }

   provisioner "remote-exec" {
       inline = [

           # install salt-minion
           "wget -O - http://bootstrap.saltstack.org | sudo sh"
       ]
    }

    provisioner "file" {

         # copy minion file
        source = "../salt/prod/minion"
        destination = "/etc/salt/minion"
    }

   provisioner "file" {

       # copy top.sls and init.sls files
       source = "../salt/roots"
       destination = "/etc/salt/roots"
   }

   provisioner "remote-exec" {
       inline = [

          # tell salt-minion to look for the state tree in
          # the local file system, with the --local flag.
         "salt-call --local state.highstate -l debug"
       ]
   }

}

下面是代码块null_resource.provision_last

resource "null_resource" "provision_last" {
    connection {
        user = "root"
        type = "ssh"
        private_key = "${file("./.ssh/prv_key")}"
        host = "${element(digitalocean_droplet.droplet.*.ipv4_address, count.index)}"
        timeout = "2m"
    }

   provisioner "file" {
       source = "../site/index.html"
       destination = "/usr/nginx/html/site/index.html"
   }

   provisioner "file" {
       source = "../site/assets"
       destination = "/usr/nginx/site"
   }

  provisioner "remote-exec" {
      inline = [
          "mv /usr/nginx/html/site/build/index.html /usr/nginx/html/site/index.html"
      ]
   }

}

我不知道我做错了什么。据我所知,它应该能够污染这些资源中的每一个。这是我在命令行上执行的操作terraform taint null_resource.provision_lastterraform taint null_resource.provision_first

答案1

我的命令中缺少模块路径。更多详细信息这里

正确的写法如下:

terraform taint -module=MODULENAME TYPE.NAME

例如,如果我的模块名为hosting

module "hosting" {
    ...
}

如果我想污染以下资源:

resource "null_resource" "provision_last" {
    ...
}

我需要做以下事情:

terraform taint -module=hosting null_resource.provision_last

相关内容