Quick notes to use the serverless framework to deploy a Node project on AWS

Intro

serverless framework consists of an open source CLI and a hosted dashboard to provide you with full serverless application lifecycle management.

The purpose of the article is to provide you a quick configuration to get started with i…


This content originally appeared on DEV Community and was authored by rounakcodes

Intro

serverless framework consists of an open source CLI and a hosted dashboard to provide you with full serverless application lifecycle management.

The purpose of the article is to provide you a quick configuration to get started with it.

Install serverless cli

npm i -g serverless

Configure serverless to use AWS

serverless config credentials --provider aws --key <access-key-id> --secret <secret-access-key> --profile <profileName>

If you do not wish to provide secrets in the shell, use ~/.aws/credentials file to save credentials in the following format:

[<Enter profile name here>]
aws_access_key_id=*********
aws_secret_access_key=***************
[<Enter another profile name here>]
aws_access_key_id=*******************
aws_secret_access_key=**********************

Create a new project (nodejs)

serverless create --template aws-nodejs --path myServerlessProject

The following files are created:
handler.js
.npmignore
serverless.yml

In serverless.yml, add profile and region
image

Deploy to AWS

In a shell, run
sls deploy

After every change in serverless.yml, you must run this command to deploy the changes.

Add a S3 bucket

In serverless.yml add:

image

Add a plugin

In a shell, run

npm i --save serverless-s3-sync

In serverless.yml add:

image

Configure the plugin

Example configuration for s3sync plugin

image

Add lambda functions

In serverless.yml add:

image

Enable debug when deploying

In a shell, run
SLS_DEBUG=* sls deploy

Example config of serverless.yml

image


This content originally appeared on DEV Community and was authored by rounakcodes


Print Share Comment Cite Upload Translate Updates
APA

rounakcodes | Sciencx (2021-05-18T02:07:11+00:00) Quick notes to use the serverless framework to deploy a Node project on AWS. Retrieved from https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/

MLA
" » Quick notes to use the serverless framework to deploy a Node project on AWS." rounakcodes | Sciencx - Tuesday May 18, 2021, https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/
HARVARD
rounakcodes | Sciencx Tuesday May 18, 2021 » Quick notes to use the serverless framework to deploy a Node project on AWS., viewed ,<https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/>
VANCOUVER
rounakcodes | Sciencx - » Quick notes to use the serverless framework to deploy a Node project on AWS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/
CHICAGO
" » Quick notes to use the serverless framework to deploy a Node project on AWS." rounakcodes | Sciencx - Accessed . https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/
IEEE
" » Quick notes to use the serverless framework to deploy a Node project on AWS." rounakcodes | Sciencx [Online]. Available: https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/. [Accessed: ]
rf:citation
» Quick notes to use the serverless framework to deploy a Node project on AWS | rounakcodes | Sciencx | https://www.scien.cx/2021/05/18/quick-notes-to-use-the-serverless-framework-to-deploy-a-node-project-on-aws/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.