Jamills102
Jamills102

Reputation: 103

Cloudformation how to Sub inside of a ImportValue inside of a Sub?

I feel I have tried just about every combination for this to work, and have come up empty handed. Has anyone done this? I am trying to reference an import value inside of a sub while referencing the the parameter ApiStack. Appreciate any advice!

LambdaPermission:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunction
      FunctionName: !GetAtt MyLambdaFunction.Arn
      Principal: apigateway.amazonaws.com
      SourceArn: !Sub 
                    - arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGateway}/*/POST/CreateBofAParameter
                    - ApiGateway: !ImportValue 
                        'Fn::Sub': '${ApiStack}--APIID'

Upvotes: 7

Views: 3202

Answers (2)

Ignat Sachivko
Ignat Sachivko

Reputation: 354

The same to used in the question code structure worked for me, thus, as mentioned in the comments, the issue is not related to Sub / ImportValue precedence or format.

  Arn: !Sub
    - "arn:aws:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:access-point/${VariableToImport}"
    - VariableToImport: !ImportValue
        'Fn::Sub': "${SubVariable}-some-id"

Upvotes: 2

Marcin
Marcin

Reputation: 238727

You have extra '. It should be:

'Fn::Sub': "${ApiStack}--APIID"

Upvotes: -1

Related Questions