简体   繁体   English

CloudFormation YAML 结合 FN::GETAtt 和 !Ref 以列出 id

[英]CloudFormation YAML combining FN::GEtAtt and !Ref to list ids

Was wrestling with the CloudFormation syntax of Generating VPCSecurityGroupIds (1 in my case).正在与生成 VPCSecurityGroupIds(在我的例子中为 1)的 CloudFormation 语法搏斗。 I have the below yaml, basically attempting to reference the parameter SecurityGroupName inside the GetAtt function.我有下面的yaml,基本上是试图引用GetAtt function中的参数SecurityGroupName。 Unfortunatley I get the "Parameters [SecurityGroupName] must have values when I know I am passing in correct SecurityGroupName value. Any insight to this nesting is greatly appreciated.不幸的是,当我知道我传递了正确的 SecurityGroupName 值时,我得到“参数 [SecurityGroupName] 必须具有值。非常感谢对此嵌套的任何见解。

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

  Translates to

  Properties:
    VpcSecurityGroupIds:
    - Fn:G:GetAtt:
      - Ref: SecurityGroupName
      - GroupId
      

try this:尝试这个:

Properties:
    VpcSecurityGroupIds:
       - Fn::GetAtt:
          - !Ref SecurityGroupName
          - GroupId

I have it working in several places.我让它在几个地方工作。 Also include resource Type in sample, will be much easier to find what you talk about.在示例中还包括资源类型,将更容易找到您所谈论的内容。

also to make sure sure you do pass SecurityGroupName value, add it to Parameters with set default.还要确保您确实传递了SecurityGroupName值,请将其添加到设置默认值的参数中。

You can't do this .不能这样做 Argument to Fn::GetAtt can't be any function. Fn::GetAtt的参数不能是任何 function。 From docs :来自文档

For the Fn::GetAtt logical resource name, you can't use functions .对于 Fn::GetAtt 逻辑资源名称,您不能使用 functions You must specify a string that's a resource's logical ID.您必须指定一个作为资源逻辑 ID 的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM