Terraform是否可以具有如下目录结构:
├── environments
│ └── production
│ ├── app1
│ ├── instances.tf
│ ├── app2
│ └── shared
│ ├── iam.tf
│ └── security_groups.tf
└── modules
└── iam
└── node
environments/production/{app1, app2, shared}
各自具有自己的地形状态,并且彼此独立。但是,从app1和app2中,我需要从共享中引用模块输出变量,例如安全组,IAM等。
所以environments/production/shared/iam.tf
看起来像:
module "iam" {
source = "../../../modules/iam"
var1 = "foo"
var2 = "bar"
var3 = "car"
var4 = "nar"
}
然后如何从app1
或app2
引用iam
中shared
的实例?
environments/production/app1/instances.tf
:
module "app1" {
source = "../../../modules/node"
iam_profile_id = { how do I reference the IAM module from shared here?
// shared.module.iam.profile_id?
}