Skip to content

Commit ab65f28

Browse files
Merge pull request #4 from laironacosta/feature/update-readme
feat: adding readme with the instructions
2 parents 363151f + 880f053 commit ab65f28

File tree

2 files changed

+93
-27
lines changed

2 files changed

+93
-27
lines changed

.github/workflows/aws.yml

-25
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
# This workflow will build and push a new container image to Amazon ECR,
2-
# and then will deploy a new task definition to Amazon ECS, when a release is created
3-
#
4-
# To use this workflow, you will need to complete the following set-up steps:
5-
#
6-
# 1. Create an ECR repository to store your images.
7-
# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`.
8-
# Replace the value of `ECR_REPOSITORY` in the workflow below with your repository's name.
9-
# Replace the value of `aws-region` in the workflow below with your repository's region.
10-
#
11-
# 2. Create an ECS task definition, an ECS cluster, and an ECS service.
12-
# For example, follow the Getting Started guide on the ECS console:
13-
# https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun
14-
# Replace the values for `service` and `cluster` in the workflow below with your service and cluster names.
15-
#
16-
# 3. Store your ECS task definition as a JSON file in your repository.
17-
# The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`.
18-
# Replace the value of `task-definition` in the workflow below with your JSON file's name.
19-
# Replace the value of `container-name` in the workflow below with the name of the container
20-
# in the `containerDefinitions` section of the task definition.
21-
#
22-
# 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
23-
# See the documentation for each action used below for the recommended IAM policies for this IAM user,
24-
# and best practices on handling the access key credentials.
25-
261
on:
272
push:
283
branches:

README.md

+93-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,93 @@
1-
# git-deploy-aws-ecs
2-
Deploy to Amazon ECS
1+
# Deploy: Dockerized Microservice to AWS ECS (EC2 instance)
2+
This project shows how to deploy a dockerized Golang microservice on AWS ECS using Github Actions. Emphasizing that the same process works for any microservice deployed in another language, because the starting point is to have the microservice dockerized.
3+
4+
Before we start, it is important to list the steps that Github, or we ourselves must execute if we do not use Github Actions to make our microservice available to an EC2 instance.
5+
6+
Workflow:
7+
8+
- Build and push a new container image to Amazon ECR.
9+
- Deploy a new task definition to Amazon ECS.
10+
- Check the service using the public IP of the configured EC2 or ELB.
11+
12+
## Table of Contents
13+
14+
- [Installing Go](#installing-go)
15+
- [Local Installation](#local-installation)
16+
- [Editors](#editors)
17+
- [Installing the repository](#installing-the-repository)
18+
- [Configuration](#configuration)
19+
- [Dependencies](#dependencies)
20+
- [Required files in your repo](#required-files-in-your-repo)
21+
- [Set-up steps](#set-up-steps)
22+
- [Running](#running)
23+
24+
## Installing Go
25+
26+
### Local Installation
27+
28+
https://www.ardanlabs.com/blog/2016/05/installing-go-and-your-workspace.html
29+
30+
## Editors
31+
32+
**Visual Studio Code**
33+
https://code.visualstudio.com/Updates
34+
https://github.com/microsoft/vscode-go
35+
36+
**VIM**
37+
http://www.vim.org/download.php
38+
http://farazdagi.com/blog/2015/vim-as-golang-ide/
39+
40+
**Goland**
41+
https://www.jetbrains.com/go/
42+
43+
## Installing the repository
44+
45+
From a command prompt, issue the following commands:
46+
47+
```sh
48+
mkdir -p $(go env GOPATH)/src/github.com/laironacosta && cd $_
49+
git clone https://github.com/laironacosta/git-deploy-aws-ecs.git
50+
```
51+
52+
*NOTE:* This assumes you have Git installed. If you don’t, you can find the installation instructions here: https://git-scm.com/
53+
54+
## Configuration
55+
56+
### Dependencies
57+
58+
The only dependencies to start the configuration of your project are:
59+
60+
- `Dockerfile`: You must have implemented the Dockerfile of your microservice.
61+
- `AWS Console Access`: You must have access to the AWS console.
62+
- `AWS Credentials`: You must have aws credentials configured on your machine to be able to execute commands to AWS.
63+
- `Github`: Your repository must be versioned on Github and you must have access.
64+
65+
### Required files in your repo
66+
67+
You must create two files in order to deploy the microservice on AWS ECS using Github actions:
68+
69+
1. `.github/workflows/aws.yml`: This file contains the entire workflow that will build and push a new container image to Amazon ECR, and then deploy a new task definition to Amazon ECS, when a condition is met in Github such as doing Push to branch develop. (copy the example code from the repo)
70+
2. `task-definition.json`: This file contains the details of your container definition on AWS.
71+
72+
### Set-up steps
73+
74+
#### 1. Create an ECR repository to store your images
75+
- For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`.
76+
- Replace the value of `ECR_REPOSITORY` in the workflow file (`aws.yml)` with your repository's name.
77+
- Replace the value of `aws-region` in the workflow file (`aws.yml)` with your repository's region.
78+
79+
#### 2. Create an ECS task definition, an ECS cluster, and an ECS service
80+
- For example, follow the Getting Started guide on the ECS console: https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun
81+
- Replace the values for `service` and `cluster` in the workflow file (`aws.yml)` with your service and cluster names.
82+
83+
#### 3. Store your ECS task definition as a JSON file in your repository
84+
- The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`.
85+
- Replace the value of `task-definition` in the workflow file (`aws.yml)` with your JSON file's name.
86+
- Replace the value of `container-name` in the workflow file (`aws.yml)` with the name of the container in the `containerDefinitions` section of the task definition.
87+
88+
#### 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
89+
- See the documentation for each action used below for the recommended IAM policies for this IAM user, and best practices on handling the access key credentials.
90+
91+
## Running
92+
93+
After configuring all the above, it is time to push the changes to your Github repository and after the automatic execution of the workflow in Github Actions, you could validate the availability of your app in your EC2 instance.

0 commit comments

Comments
 (0)