amazon-web-services - 参数部分中的跨堆栈引用

标签 amazon-web-services aws-cloudformation

我正在尝试弄清楚如何将 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/

相关文章:

aws-cloudformation - 如何向从 CloudFormation 创建的 AWS ElasticSearch 添加保留策略?

ruby - 如何通过 Ruby 连接到 Amazon EMR Hive?

amazon-web-services - AWS 云信息 : Setting up more than 1 condition for IpAddress

python - Boto3云信息错误: Template format error: unsupported structure

amazon-web-services - EC2 实例中的 API 成功使用端口 5000,但是当从负载均衡器到达时,端口不工作

amazon-web-services - 如何在CDK中获取AWS IoT自定义终端节点?

amazon-web-services - 用于启动 EC2 实例的 CloudFormation 模板

ruby - 我应该使用什么 gem 来使用 AWS

python - 减少用于在 CloudFront 上部署的 python AWS Lambda 大小

javascript - AWS Cloudwatch 获取警报名称