6
votes

I am trying to use aws-sam to develop / simulate my API Gateway locally. My API gateway makes liberal use of the HTTP proxy integrations. The production Resource looks like this:

Screenshot of an HTTP Proxy integration on an API Gateway Resource Method

All of the aws-sam examples which I've found, as well as related documentation and Q&A, use the Lambda integrations / have a hard dependency on a Lambda function being the proxied resource, versus an HTTP Proxy integration.

Is there a way to define an HTTP Proxy resource for an aws-sam application? (As opposed to a Lambda Proxy resource?)

Related:

1

1 Answers

1
votes

Yes, SAM is just a Cloud Formation transform. So you can still create traditional CloudFormation objects as usual. You might be able to also attach it to your Serverless::API but I am less confident about that.

Resource:
  Api:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Description: A test API
      Name: MyRestAPI

    Type: 'AWS::ApiGateway::Resource'
    Properties:
      ParentId: !GetAtt Api.RootResourceId
      RestApiId: !Ref Api
      PathPart: '{proxy+}'

or possibly (untested):

Resource:
  Api:
    Type: 'AWS::Serverless::Api'
    Properties:
      Description: A test API
      Name: MyRestAPI

    Type: 'AWS::ApiGateway::Resource'
    Properties:
      ParentId: !GetAtt Api.RootResourceId
      RestApiId: !Ref Api
      PathPart: '{proxy+}'