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:
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:
However, if your Lambda is only ever invoked by API Gateway, use the proxy integration with these guidelines: Avoid greedy path variables, except perhaps for a catch-all 404. Avoid using the ANY method. Define request models and enable request validation (remember it's off by default).
AWS API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. Lambda is function as a service(FAAS) product of AWS. The combination of these two services is amazing and it is slowly replacing the traditional backend.
API calls are made from various external apps; they are processed by API Gateway, and are routed to Lambda for processing. Lambda may use other AWS services to complete a request, and, once complete, it sends back the response to the external app via API gateway.
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+}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With