@irvingjs/aws-lambda v6.16.0
AWS Lambda Integration
This package can be used to facilitate the integration of Irving to AWS Lambda.
The @irvingjs/aws-lambda package makes use of the serverless-http package to better integrate to AWS Lambda. We also recommend using the serverless package to deploy to AWS. You can also integrate the deployment to AWS in your CI (process), if desired.
Installation
npm install -g serverlessand set it up to connect to AWS properly- You should have the
serverlessorslscommands available and properly authenticated locally.
Project setup
npm install @irvingjs/aws-lambda- In the root of your Irving project, create an
index.js(this file should have the same as the one in yourpackage.jsonmainkey) file with the following content:
// index.js
module.exports.irving = require('@irvingjs/core/server');The
irvingname exported will be the entry point for your AWS Lambda function to run your Irving site. 3. You also need to add theaws-lambdato the list of packages inirving.config.server.js. There is no need to add it to theirving.config.jssince this is a server configuration:// irving.config.server.js
const lambdaConfig = require('@irvingjs/aws-lambda');
const config = { name: 'irving-dev-app', packages: lambdaConfig, , };
module.exports = config;
4. In the root of Irving project, create a `serverless.yml` file with the following content (you can update as needed):
```yml
service: irving
provider:
name: aws
runtime: nodejs12.x
region: sa-east-1
memorySize: 512
functions:
app:
handler: index.irving # The same as your index.js exported key.
events:
- http:
path: /
method: GET
- http:
path: /{any+}
method: GET- When you are ready to deploy your app,
npm install --productionto remove development dependencies (serverlessdoes this for you but it is a good practice) - And run
npm run buildto build the app files - Finally, run
sls deployorserverless deploy
Be aware of the 50MB limit for direct upload/deployment from AWS.
Checking AWS Lambda support locally
To test AWS Lambda support locally, we recommend installing the serverless-offline package.Here are the steps if you need to use this package:
- Set up your project for AWS Lambda integration.
npm install serverless-offline- Add the
serverless-offlineplugin to the list:
service: irving
plugins:
- serverless-offline
...- Finally, run
serverless offlineorsls offline.
About Large Apps/Sites (Bundle Size)
If you have a really large site/app, your bundle size will probably surpass the AWS Lambda upload limit of 50MB. We are testing with the serverless-webpack to find ways to optimize the bundle as much as possible for size.
More docs about it soon. :)
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago