aws-lambda-go

command module
v0.0.0-...-2326ada Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 6 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL