Sujith Gunawardhane
Sujith Gunawardhane

Reputation: 1311

How to get the Uri for the aws:lambda function as a text?

I'm trying to link an API Gateway to prefined lambda function. However it says unsupported property Uri. My lambda function is created in the given region as "SayHelloFunction".

  SayHello:
    Type: "AWS::ApiGateway::Method"
    DependsOn:
      - RootApi
      - HelloResource
    Properties:
      RestApiId: !Ref RootApi
      ResourceId: !Ref HelloResource
      HttpMethod: PUT
      MethodResponses:
        - StatusCode: 200
      AuthorizationType: NONE
      ApiKeyRequired: true
      Integration:
        IntegrationHttpMethod: PUT
        IntegrationResponses:
          - StatusCode: 200
        Type: AWS_PROXY
      Uri: 'arn:aws:apigateway:us-east-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-2:xxxxxxxxxxxx:function:SayHelloFunctionFunctionArn/invocations'

Please help.

Upvotes: 4

Views: 2837

Answers (1)

Avinash Dalvi
Avinash Dalvi

Reputation: 9301

You can set using Lambda Arn attribute by calling like below shown.

Uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${SayHelloFunction.Arn}/invocations

You will get more details here : https://github.com/aviboy2006/lambda-apigateway-sns-cnf-awsugblrdemo/blob/main/sample.yaml

Upvotes: 6

Related Questions