Build and Deploy Serverless Application with webpack

  1. Create a new repository and install required packages
  2. Create lambda handlers
  3. Setup tsconfig.json
  4. Setup webpack.config.js
  5. Setup serverless.yml
  6. Deploy and test the lambdas
npm i -g serverless
npm install -D webpack typescript ts-loader serverless-webpack webpack-node-externals terser-webpack-plugin fork-ts-checker-webpack-plugin
 npm install aws-sdk lodash @types/lodash 
touch serverless.yml
touch webpack.config.js
touch tsconfig.json

helloLambda.ts
testLambda.ts
tsconfig.json
webpack.config.js
serverless.yml
package:  
individually: true
plugins:  
- serverless-webpack
custom:  
webpack:
webpackConfig: './webpack.config.js'
packager: 'npm'
includeModules:
forceExclude:
- aws-sdk
serverless config credentials --provider aws --key <Access Key ID> --secret <Secret Access Key>
sls deploy --config serverless.yml
serverless deployment result
sls invoke -f  testLambda  -l
lambda invoke result
sls remove 
remove serverless stack

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anis Alam

Anis Alam

Full Stack Engineer | Building Beautiful UI | Problem Solver