Serverless API deployment AWS

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

This post is about Serverless API deployment AWS

Introduction

What is serverless computing, and how can you use it effectively to build software? In this course, Serverless Computing: The Big Picture, you will learn the foundational knowledge needed to architect serverless systems. First, you will discover what it means to be serverless and how it compares to traditional software development. Next, you will explore the most important platforms and technologies for delivering serverless solutions. Finally, you will see examples of serverless architectures that you can implement. When you are finished with this course, you will have the knowledge needed to start designing serverless systems.

User demand for new functions grows faster than your development processes can meet. As a result, you need a platform, methods, application services, and tools that can keep up without forcing you to leave behind the existing apps that your customers depend on.
Cloud-native development provides strategic flexibility and agility to build and run applications on any cloud and embodies well-known development best practices of continuous integration and deployment. Enterprises are also modernizing enterprise middleware. A cloud-native platform is a modern app platform that can replace aging and expensive application servers.

Serverless API

A cloud-native development platform can empower you to respond to market trends and quickly turn ideas into products and services. But how do organizations get started? How do teams design and implement a strategy specific to their current situations and needs?
This e-book presents enterprise architects and IT leaders with a step-by-step guide for tackling modern IT strategy.

  • Lower costs – Serverless computing is generally very cost-effective, as traditional cloud providers of backend services (server allocation) often result in the user paying for unused space or idle CPU time.
  • Simplified scalability – Developers using serverless architecture don’t have to worry about policies to scale up their code. The serverless vendor handles all of the scaling on demand.
  • Simplified backend code – With FaaS, developers can create simple functions that independently perform a single purpose, like making an API call.
  • Quicker turnaround – Serverless architecture can significantly cut time to market. Instead of needing a complicated deploy process to roll out bug fixes and new features, developers can add and modify code on a piecemeal basis.

Installing Serverless API CLI via npm

# npm install -g serverless
	
# Create a new serverless project
# serverless

# Move into the newly created directory
cd your-service-name

Required files handler.py and serverless.yml

# cat handler.py
import json


def hello(event, context):
    body = {
        "message": "Go Serverless v3.0! Your function executed successfully!",
        "input": event,
    }

    return {"statusCode": 200, "body": json.dumps(body)}
# cat serverless.yml
service: aws-python # NOTE: update this with your service name

frameworkVersion: '3'

provider:
  name: aws
  runtime: python3.8

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get

Deploying

If you haven’t done so already within the serverless command, you can deploy the project at any time by running:

# serverless deploy

Get the API URL generated by the command

Deploying aws-python-http-api-project to stage dev (us-east-1)

✔ Service deployed to stack aws-python-http-api-project-dev (133s)

dashboard: https://app.serverless.com/unixcop/apps/aws-python-http-api-project/aws-python-http-api-project/dev/us
-east-1
endpoint: GET - https://igvrkkobzf.execute-api.us-east-1.amazonaws.com/
functions:
  hello: aws-python-http-api-project-dev-hello (85 kB)
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Neil
Neil
Treat your password like your toothbrush. Don’t let anybody else use it, and get a new one every six months.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook