https://github.com/swarajkumarsingh/aws-lambda-go
Detailed Demonstration how to use Deploy Golang Server to AWS API-GATEWAY & AWS Lambda via serverless framework
https://github.com/swarajkumarsingh/aws-lambda-go
api-gateway aws cloud-computing go lambda
Last synced: about 1 month ago
JSON representation
Detailed Demonstration how to use Deploy Golang Server to AWS API-GATEWAY & AWS Lambda via serverless framework
- Host: GitHub
- URL: https://github.com/swarajkumarsingh/aws-lambda-go
- Owner: swarajkumarsingh
- License: mit
- Created: 2024-01-09T13:21:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T17:23:51.000Z (over 2 years ago)
- Last Synced: 2025-05-19T00:38:37.840Z (about 1 year ago)
- Topics: api-gateway, aws, cloud-computing, go, lambda
- Language: Go
- Homepage: https://github.com/swarajkumarsingh/aws-lambda-go
- Size: 4.13 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
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.

## Table of Contents
- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
- [Configuration](#configuration)
- [Building the Go Server](#building-the-go-server)
- [Deploying to AWS Lambda](#deploying-to-aws-lambda)
- [Testing](#testing)
- [Clean-Up](#clean-up)
- [Contributing](#contributing)
- [License](#license)
## Prerequisites
Before you begin, make sure you have the following installed and set up:
- [Go](https://golang.org/doc/install)
- [Serverless CLI](https://www.serverless.com/framework/docs/getting-started)
## Getting Started
Clone this repository to your local machine:
```bash
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
```
## 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.