https://github.com/swarajkumarsingh/aws-ecr-golang
A Comprehensive Guide on Using Serverless Architecture to Deploy Dockerized Golang Server to AWS ECR & ECS
https://github.com/swarajkumarsingh/aws-ecr-golang
aws aws-cli ecr ecs go golang serverless
Last synced: 8 months ago
JSON representation
A Comprehensive Guide on Using Serverless Architecture to Deploy Dockerized Golang Server to AWS ECR & ECS
- Host: GitHub
- URL: https://github.com/swarajkumarsingh/aws-ecr-golang
- Owner: swarajkumarsingh
- License: mit
- Created: 2024-01-10T10:28:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-10T10:43:55.000Z (over 1 year ago)
- Last Synced: 2024-12-28T03:42:15.411Z (9 months ago)
- Topics: aws, aws-cli, ecr, ecs, go, golang, serverless
- Language: Makefile
- Homepage: https://github.com/swarajkumarsingh/aws-ecr-golang
- Size: 6.84 KB
- 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 Dockerized Go server to AWS ECR & ECS. By leveraging AWS ECR & ECS, you can host your Go application with minimal infrastructure management and cost.

## Table of Contents
- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
- [Configuration](#configuration)
- [Workflow](#workflow)
- [Run Go Server](#building-the-go-server)
- [Deploying to AWS ECR](#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)
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)## Getting Started
Clone this repository to your local machine:
```bash
git clone https://github.com/swarajkumarsingh/aws-ecr-golang.git
cd aws-ecr-golang
```## Run Go Server
```
go run main.go
```## Configuration
Makefile - file contains all configs related to image deployment
```
deploy:
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin
docker build -t test-name .
docker tag test-name:latest /test-name:latest
docker push /test-name:latest
```## Workflow
- First we build our docker image
- Then we push it to AWS ECR
- Then setup AWS ECS cluster
- Create a task defining your OS, expose your port carefully
- Inside AWS ECS cluster create a service, and add your task with other configurations
- Create a Load-Balancer and set the values accordingly
- After everything succeeds, your Load-Balancer ARM url, will be url backend server url## Deploying to AWS ECR
Use serverless cli for deploying
```
make deploy
```## Testing
After you deploy, you will be given a url
```
curl
```## Clean-Up
```
- Head to your AWS console
- Search 'ECR'
- Delete the repository
- Search 'ECS'
- Delete the cluster & tasks
- Head to Load-Balancer
- Delete the load-balancer
- And all set :)
```## 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.