简体   繁体   English

如何从 Terraform 中的不同模块访问资源?

[英]How to access a resource from a different module in Terraform?

Module 'xyz' should wait 10 mins for module 'abc' residing in a diff dir.模块 'xyz' 应该等待 10 分钟让模块 'abc' 驻留在 diff 目录中。 Here are the details.这是详细信息。

root/x/main.tf根/x/main.tf

module "abc" {
  ...
}
resource "time_sleep" "wait_10_mins" {
  depends_on = [module.abc[0]]

  create_duration = "10m"
}

root/y/main.tf根/y/main.tf

module "xyz" {
  .....

  depends_on = how to access resource time_sleep.wait_10_mins here?
  
}

You seem to be very close:你似乎很接近:

You'll only need the [0] if the abc module is using count or for_each :如果 abc 模块使用countfor_each则只需要[0]

  depends_on = [
    module.abc
  ]

and

  depends_on = [
    time_sleep.wait_10_mins
  ]

Should do the trick.应该做的伎俩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM