0
provider:
  name: aws
  runtime: nodejs14.x

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
          path: /
          method: get
          RestApiId:
            Ref: TestApi // How to get reference of AWS::Serverless::Api i.e. TestApi here

resources:
  Resources:
    authFunction:
      Type: AWS::Serverless::Function
      Properties:
        CodeUri: .
        Handler: handler.hello

    TestApi:
      DependsOn: AuthFunction
      Type: AWS::Serverless::Api
      Properties:
        StageName: dev
        Auth:
            DefaultAuthorizer: LambdaRequestAuthorizer
            Authorizers:
              LambdaRequestAuthorizer:
                FunctionPayloadType: REQUEST
                FunctionArn: !GetAtt AuthFunction.Arn

Getting error:

Configuration error at 'functions.hello': unrecognized property 'RestApiId'

1 Answer 1

1

Let's first clarify a few things.

The httpApi event is using HTTP API, not REST API from AWS Api Gateway.

You can set externally created HTTP API by specifying it in the following way:

provider:
  httpApi:
    id: <your http api reference>

If you'd like to use REST API, then you would need to use http event type and set it like this:

provider:
  apiGateway:
    restApiId: <your rest api reference>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.