Terraform,在污点上出现“模块根目录没有资源”错误

nun*_*nop 3 terraform

获得一个The module root has no resources上污点错误。我试图污染几个null_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"
       ]
   }

}
Run Code Online (Sandbox Code Playgroud)

这是以下代码块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"
      ]
   }

}
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚我做错了什么。据我所知,它应该能够污染这些资源中的每一种。这就是我在命令行上所做的:terraform taint null_resource.provision_lastterraform taint null_resource.provision_first

nun*_*nop 7

我的命令中缺少模块路径。更多细节在这里

这是正确的写法:

terraform taint -module=MODULENAME TYPE.NAME
Run Code Online (Sandbox Code Playgroud)

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

module "hosting" {
    ...
}
Run Code Online (Sandbox Code Playgroud)

如果我想污染以下资源:

resource "null_resource" "provision_last" {
    ...
}
Run Code Online (Sandbox Code Playgroud)

我需要执行以下操作:

terraform taint -module=hosting null_resource.provision_last
Run Code Online (Sandbox Code Playgroud)