CloudFormation YAML 结合 FN::GEtAtt 和 !Ref 来列出 id

use*_*236 1 yaml amazon-web-services aws-cloudformation

正在努力解决生成 VPCSecurityGroupIds 的 CloudFormation 语法(在我的例子中为 1)。我有下面的 yaml,基本上是尝试引用 GetAtt 函数内的参数 SecurityGroupName 。不幸的是,当我知道我传递了正确的 SecurityGroupName 值时,我得到“参数 [SecurityGroupName] 必须具有值”。非常感谢对此嵌套的任何见解。

  Properties:
    VpcSecurityGroupIds:
      - "Fn::GetAtt": [ !Ref SecurityGroupName , "GroupId"]

  Translates to

  Properties:
    VpcSecurityGroupIds:
    - Fn:G:GetAtt:
      - Ref: SecurityGroupName
      - GroupId
      
Run Code Online (Sandbox Code Playgroud)

Mar*_*cin 5

不能这样做。参数 toFn::GetAtt不能是任何函数。来自文档

对于Fn::GetAtt 逻辑资源名称,不能使用functions。您必须指定一个作为资源逻辑 ID 的字符串。