Define API with external openapi spec

EDITED: See my response below for my progress. I only need to find out how to refer to a function ARN from an openApi spec declared in the resources block.

I’m trialing the serverless.com with AWS as the provider. I’d like to do a simple hello world app with API Gateway and Lambda, where I publish the API from an openapi spec.

I have seen in this forum post that I need to declare the spec as a resource in the serverless.yml file, but when doing so I get the following error when doing sls deploy:

I think I have mostly correct, except that in the openapi spec file I don’t know how to correctly refer to the URI for the API I am creating (as I am creating the lambda function within the same serverless project). Is that the reason I am getting the error?

  Serverless Error ---------------------------------------

  An error occurred: ApiGatewayRestApi - Errors found during import:
  	Unable to put integration on 'GET' for resource at path '/hello': Invalid function ARN or invalid uri (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: ...).

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.16.2
     Framework Version:         1.67.3
     Plugin Version:            3.6.6
     SDK Version:               2.3.0
     Components Version:        2.29.3

I am trying the simplest example I can think of:

# serverless.yml
service: accounts-api

provider:
  name: aws
  apiName: accounts
  runtime: nodejs12.x
  stage: dev
  region: ap-southeast-2

functions:
  hello:
    handler: functions/handler.hello
    events:
      - http:
           path: /accounts
           method: GET

# The resources attribute will be sent directly to CloudFormation in raw format
resources:
    Resources:
      ApiGatewayRestApi:
        Type: 'AWS::ApiGateway::RestApi'
        Properties:
          Name: ${self:provider.apiName}-${self:provider.stage}
          Body:
            ${file(specs/simple-spec.yml)}
      ApiGatewayDeployment:
        Type: AWS::ApiGateway::Deployment
        Properties:
          RestApiId:
            Ref: ApiGatewayRestApi
          StageName: ${self:provider.stage}

and the openapi spec:

openapi: 3.0.0
info:
  version: 1.0.0
  title: Hello API
  description: Returns a hello world message
  
paths:
  /hello:
    get:
      description: Returns a hello world message              
      responses:
        '200':
          description: Successful response
      security:
      - api_key: []
      x-amazon-apigateway-auth:
        type: none          
      x-amazon-apigateway-integration:
         x-amazon-apigateway-integration:
         type: aws_proxy
         uri: arn:aws:apigateway:ap-southeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-southeast-2:idAccount:function:hello/invocations
         httpMethod: GET
         passthroughBehavior: when_no_templates
         payloadFormatVersion: 1.0

I realised that my uri under the x-amazon-apigateway-integration: attribute is not quite correct. I need to find the full ARN for the Lambda function that is created by this serverless project.

How can I dynamically refer to the lambda Arn in there? I am trying ${self:functions.hello.arn} without any success. :frowning:

Did you ever get this working.
I would like to do interface first design with openapi 3.0 and user serverless