![Terraform,在污点上收到“模块根没有资源”错误](https://linux22.com/image/680588/Terraform%EF%BC%8C%E5%9C%A8%E6%B1%A1%E7%82%B9%E4%B8%8A%E6%94%B6%E5%88%B0%E2%80%9C%E6%A8%A1%E5%9D%97%E6%A0%B9%E6%B2%A1%E6%9C%89%E8%B5%84%E6%BA%90%E2%80%9D%E9%94%99%E8%AF%AF.png)
出现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_last
:terraform 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