Git Product home page Git Product logo

aws-ecr-golang's Introduction

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.

a

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-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 <aws_ecr_image_url>
	docker build -t test-name .
	docker tag test-name:latest <aws_ecr_image_url>/test-name:latest
	docker push <aws_ecr_image_url>/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 <given-url>

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.

aws-ecr-golang's People

Contributors

swarajkumarsingh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.