【发布时间】:2022-01-18 12:09:37
【问题描述】:
请帮助理解,我如何能够在不执行的情况下将输出从一个模块传递到另一个模块?
问题是,我在我的模块“A”上找到了这样的帐号:
data "aws_caller_identity" "current" {}
output "account_id" {
value = data.aws_caller_identity.current.account_id
}
它运行良好,但是当我尝试使用模块“B”的此输出时 喜欢:
module "tgw" {
source = "../moduleA/"
}
我在“B”帐户的当前 ID 上更新了 module.tgw.account_idvalue,但希望接收 A 帐户的输出帐户 ID。
有可能以某种方式做到这一点吗?
实现示例:
在帐户“A”(帐户 ID 111111111111)上,实现代码:
data "aws_caller_identity" "current" {}
output "account_id" {
value = data.aws_caller_identity.current.account_id
}
在帐户“B”(帐户 id 222222222222)上,实现:
module "tgw" {
source = "../moduleA/"
}
locals {
account_a_id = module.tgw.account_id
}
预期结果:
account_a_id = 111111111111
当前结果:
account_a_id = 222222222222
【问题讨论】:
-
您是否质疑我们如何将值从一个模块传递到另一个模块,或者您已经这样做了但它在错误的帐户中更新?
-
不清楚你到底在问什么,但听起来你需要为模块声明一个变量,并提供第一个模块的输出作为第二个模块声明的输入。
标签: amazon-web-services terraform