'CloudFormation YAML combining FN::GEtAtt and !Ref to list ids

Was wrestling with the CloudFormation syntax of Generating VPCSecurityGroupIds (1 in my case). I have the below yaml, basically attempting to reference the parameter SecurityGroupName inside the GetAtt function. 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.

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

  Translates to

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


Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lukas Liesis