Skip to content

Instantly share code, notes, and snippets.

@ambujraj
Created October 15, 2021 12:34
Show Gist options
  • Save ambujraj/3584e1038a016fa929fef293195d381e to your computer and use it in GitHub Desktop.
Save ambujraj/3584e1038a016fa929fef293195d381e to your computer and use it in GitHub Desktop.
AWS lambda deploy
const awsServerlessExpress = require('aws-serverless-express');
const app = require('./app');
const server = awsServerlessExpress.createServer(app)
module.exports.universal = (event, context) => awsServerlessExpress.proxy(server, event, context);
const app = require('./app.js');
// Server listen
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log("Server listening to port: "+port);
});
service: api-gateway-demo
provider:
name: aws
runtime: nodejs14.x
stage: production
region: ap-south-1
functions:
api:
handler: lambda.universal
events:
- http: ANY {proxy+}
- http: ANY /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment