将 ImportValue 导入 CFN 参数默认值的 YAML 语法

YAML Syntax for ImportValue into CFN Parameter Default

我正在努力使用 YAML 语法将另一个 CFN 堆栈导出的值导入新堆栈中参数的默认值。

我现在有的是:

Parameters:
  DBEndpoint:
    Description: Hostname endpoint for RDS Database
    Type: String
    Default: Fn::ImportValue: 'db-endpoint'

其中 db-endpoint 是由以下 YAML 模板片段导出的值:

Outputs:
  dbhost:
    Description: "RDS Endpoint Address"
    Value: !GetAtt DB.Endpoint.Address
    Export:
      Name: db-endpoint

导出工作正常,但在尝试使用 ImportValue 行加载模板时出现解析错误 (Template format error: YAML not well-formed. )。


更新:

我想我现在可以正确解析 YAML,但现在遇到新错误。

Parameters:
  DBEndpoint:
    Description: Hostname endpoint for RDS Database
    Type: String
    Default: !ImportValue 'db-endpoint'

我收到一个错误 Template format error: Every Default member must be a string.

所以,看起来更近了,但仍然没有用。

This answer 暗示这甚至不可能...是这样吗?

!ImportValue 'db-endpoint' 不能用于Parameters。它只能用于模板的 ResourcesOutputs。您必须“手动”(又名,在 CloudFormation 之外,例如通过包装脚本)将 DBEndpoint 的默认值设置为 db-endpoint.

的实际值