Skip to content

swarajkumarsingh/aws-lambda-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploying a Go Server to AWS Lambda

This repository provides a simple guide and example code for deploying a Go server to AWS Lambda. By leveraging AWS Lambda, you can host your Go application with minimal infrastructure management and cost.

a-removebg-preview

Table of Contents

Prerequisites

Before you begin, make sure you have the following installed and set up:

Getting Started

Clone this repository to your local machine:

git clone https://github.com/swarajkumarsingh/aws-lambda-go.git
cd aws-lambda-go

Building the Go Server

Build your Go server binary:

make build
make build-windows (for windows optional)

Configuration

serverless.yml - file contains all configs related to deployment options

service: serverless-rest-api-3
frameworkVersion: '>=1.28.0'
provider:
  name: aws
  runtime: go1.x
  stage: ${opt:stage, 'dev'}
  region: ap-south-1

functions:
  api:
    handler: bin/main
    events:
      - http:
          path: /ping
          method: get
          cors: true
      
package:
  patterns:
    - '!*/**'
    - bin/main

Deploying to AWS Lambda

Use serverless cli for deploying

make deploy(this will build the project and deploy it)

Testing

After you deploy, you will be given a url

curl <give-url>

Clean-Up

- Head to your AWS console
- Search 'CloudFormation'
- Select your stack via name
- Delete it
- Verify this, by going to lambda make sure there is no running lambda function via your project name

Contributing

If you find any issues or have improvements, feel free to open an issue or submit a pull request. Contributions are welcome!

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Detailed Demonstration how to use Deploy Golang Server to AWS API-GATEWAY & AWS Lambda via serverless framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published