Home > Blockchain >  CloudFormation YAML combining FN::GEtAtt and !Ref to list ids
CloudFormation YAML combining FN::GEtAtt and !Ref to list ids

Time:02-04

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
      

CodePudding user response:

You can't do this. Argument to Fn::GetAtt can't be any function. From docs:

For the Fn::GetAtt logical resource name, you can't use functions. You must specify a string that's a resource's logical ID.

CodePudding user response:

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.

  •  Tags:  
  • Related