来自单独Terraform项目中的模块的参考模块

时间:2019-02-21 18:12:41

标签: terraform

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"
}

然后如何从app1app2引用iamshared的实例?

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?
}

0 个答案:

没有答案