简体   繁体   中英

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. Here are the details.

root/x/main.tf

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

  create_duration = "10m"
}

root/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 :

  depends_on = [
    module.abc
  ]

and

  depends_on = [
    time_sleep.wait_10_mins
  ]

Should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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