首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能污染null_resource

不能污染null_resource
EN

Stack Overflow用户
提问于 2019-03-07 01:33:41
回答 3查看 1.2K关注 0票数 1

我得到了terraform 0.11.11。图中所示的资源在根模块中

代码语言:javascript
复制
$ terraform graph
digraph {
        compound = "true"
        newrank = "true"
        subgraph "root" {
                "[root] data.template_file.default" [label = "data.template_file.default", shape = "box"]
                "[root] data.template_file.etcd" [label = 
...
                "[root] null_resource.service_resolv_conf" [label = "null_resource.service_resolv_conf", shape = "box"]
...

但试图污染它的人说它不是:

代码语言:javascript
复制
$ terraform taint null_resource.service_resolv_conf
The resource null_resource.service_resolv_conf couldn't be found in the module root.

更新

代码语言:javascript
复制
$ terraform state list|grep resolv_conf 
null_resource.service_resolv_conf[0] 
null_resource.service_resolv_conf[1] 

然后我试着:

代码语言:javascript
复制
$ terraform taint null_resource.service_resolv_conf[0] 

The resource null_resource.service_resolv_conf[0] couldn't be found in the module root. 

代码语言:javascript
复制
$ terraform taint null_resource.service_resolv_conf 
The resource null_resource.service_resolv_conf couldn't be found in the module root.
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-03-12 01:23:10

毕竟我找到了解决方案

它出现了,然后当有更多的主机在基于列表的连接中(使用'count')

代码语言:javascript
复制
resource "null_resource" "provision_docker_registry" {
  count      = "${length(local.service_vms_names)}"
  depends_on = ["null_resource.service_resolv_conf"]

  connection {
    user        = "cloud-user"
    private_key = "${file("${path.module}/../ssh/${var.os_keypair}.pem")}"
    host        = "${element(local.service_fip, count.index)}"
  }

通过在点后指定索引来污染资源,例如

代码语言:javascript
复制
$ terraform taint null_resource.provision_docker_registry.0
The resource null_resource.provision_docker_registry.0 in the module root has been marked as tainted!

瞧!

我不可能在文档中找到这一点。希望这对某些人有帮助。

票数 0
EN

Stack Overflow用户

发布于 2019-03-07 07:56:40

terraform graph为您提供了有关资源及其关系的完整图景。

但它不是一个很好的命令,用于排除故障和了解资源在terraform *.tfstate文件中的命名方式。

我建议使用terraform state list运行,这样你就可以很容易地知道如何污染列表中的某个资源。

代码语言:javascript
复制
terraform state list
terraform taint <copy resource directly from above list>
票数 4
EN

Stack Overflow用户

发布于 2020-06-26 23:38:21

对于那些来到这个帖子寻找terraform污点/未污点null_resource的人,这里有@victor-m在Cannot taint null_resource上发布的正确且有效的答案

代码语言:javascript
复制
terraform taint -module=name null_resource.name

untaint命令也是如此。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55029041

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档