3

Getting a The module root has no resources error on taint. I'm trying to taint a couple of null_resources. Here's the code block for 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"
       ]
   }

}

And here's the code block for 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"
      ]
   }

}

I cannot figure it out what I'm doing wrong. As far as I can see it should be able to taint each one of these resources. This is what I'm doing on the command line: terraform taint null_resource.provision_last and terraform taint null_resource.provision_first

nunop
  • 211
  • 3
  • 10

1 Answers1

7

I was missing the module path on my command. More details here.

This is the right way to write it:

terraform taint -module=MODULENAME TYPE.NAME

For instance, if my module was named hosting:

module "hosting" {
    ...
}

And if I wanted to taint the following resource:

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

I would need to do the following:

terraform taint -module=hosting null_resource.provision_last
nunop
  • 211
  • 3
  • 10