我正在尝试弄清楚如何将 CloudFormation 堆栈的输出作为参数传递给另一个 CloudFormation 堆栈,特别是通过 Parameters section CloudFormation 定义。
假设 StackA 正在导出输出:-
Outputs:
TargetGroupArn:
Description: "Target Group ARN"
Export: {Name: TargetGroupArn}
Value: {Ref: TargetGroup}
StackB 可以在其定义中包含参数吗:-
Parameters:
TargetGroupArn:
Type: String
Default:
Fn::ImportValue: TargetGroupArn
注意:我知道可以通过 Fn::ImportValue
在资源部分中任何需要的地方获取 TargetGroupArn
。我对参数部分的导入特别感兴趣。
最佳答案
不,您不能将该值导入为参数默认值。
根据 documentation (强调),
You can use intrinsic functions only in specific parts of a template. Currently, you can use intrinsic functions in resource properties, outputs, metadata attributes, and update policy attributes. You can also use intrinsic functions to conditionally create stack resources.
参数不是允许使用内部函数的部分之一;由于 Fn::ImportValue
是一个内部函数,因此无法导入参数值。
关于amazon-web-services - 参数部分中的跨堆栈引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58737005/