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" ] } } 

这里是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

我错过了我的命令模块path。 更多细节在这里 。

这是写它的正确方法:

 terraform taint -module=MODULENAME TYPE.NAME 

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

 module "hosting" { ... } 

如果我想玷污以下资源:

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

我需要做到以下几点:

 terraform taint -module=hosting null_resource.provision_last