DevForth

Serverless Framework with AWS, an easy practical start

What serverless means, how Serverless Framework deploys a function to AWS Lambda in one command, and what to know about its v4 license first.

Ivan Borshchov
Ivan Borshchov
CEO & System Architect @ DevForth
Serverless Framework with AWS, an easy practical start
Serverless Framework with AWS, an easy practical start

"Serverless" doesn't mean there are no servers. It means the servers aren't your job. You give AWS a small function and say: "run this every time someone calls it". AWS starts it, runs it and stops it again. You pay for the calls, not for a machine that sits waiting all day.

Serverless Framework is a tool that packs up your code and settings and sends them to AWS for you. You describe the whole app in one file:

# serverless.yml
service: hello-api
provider:
  name: aws
  runtime: nodejs22.x
  region: eu-central-1
functions:
  hello:
    handler: handler.hello
    events:
      - httpApi: 'GET /hello'
// handler.js
module.exports.hello = async () => ({
  statusCode: 200,
  body: JSON.stringify({ message: 'Hello!' }),
});

Then run:

npm i -g serverless
serverless deploy

The first run asks you to log in and connect your AWS credentials. When the deploy finishes it prints a URL. Open it and you'll see your message. Behind the scenes the tool created a CloudFormation stack with a Lambda function, an HTTP API, permissions and logs. When you're done playing, serverless remove deletes all of it, so nothing keeps billing you.

Good to know

  • Version 4 needs a login or a license key. It is free for individuals and for companies under 2 million USD in yearly revenue. Bigger companies need a paid subscription. Version 3 is no longer maintained.
  • If that doesn't suit you, AWS SAM and AWS CDK do the same job for free.
  • Deploy with a dedicated AWS identity, never the root user.

Stuck on some serverless.yml syntax? Search GitHub code for files named serverless.yml that use the same resource. Seeing how other people wrote it is often the fastest answer.

In short: write a function, describe it in serverless.yml, run serverless deploy, and clean up with serverless remove.

Get your project quote

Free result within 48-72 hours

Related insights