Search code examples
amazon-web-servicesaws-cloudformationaws-cloudformation-custom-resource

Unable to resolve cloudformation template using !Sub


I am trying to keep apigateway DNS values in ssm parameter section. The way I used the function Select it is just printing in SSM. apiEndpoint is another resources which is working fine.

I need to change something in Value section so that I can keep the DNS name in ssm parameter.

  APIGWEndpointSSM:
    Type: AWS::SSM::Parameter
    Properties :
      Description : vpc endpoint for the nextgen apigateway.
      Name : /vpc/apigwvpcendpoint
      Type : String
      Value : https://!Sub(!Select [1, !Split [":", !Select [ 0, !GetAtt apiEndpoint.DnsEntries ]]])

Solution

  • You can use array form of Sub:

    Name: !Sub
      - "https://${dns}"
      - { dns: !Select [1, !Split [":", !Select [ 0, !GetAtt apiEndpoint.DnsEntries]]] }