Slide 1

Slide 1 text

Building My First Infrastructure The Way from EC2 to ECS 2024/06/19 @Japanglish Tech Talk

Slide 2

Slide 2 text

whoami 
 @k_zakisan - SRE role (SWE) - love competitive programming - LeetCode: Top 2% rating - https://leetcode.com/u/k-zakisan - my new challenges in this year - speak at a tech events - LT - Conference - improve my English skill - ELSA speak(App) - join English events

Slide 3

Slide 3 text

today’s topic 
 About this project - 2 years ago - containerize PHP/Laravel web application - running on EC2 server for four years - migrate the server to ECS - my first SRE-like work - through the project, I became SRE

Slide 4

Slide 4 text

beginning of project 


Slide 5

Slide 5 text

beginning of project(upgrade middleware???) 
 my boss me Hey Zakisan, Could you upgrade PHP/Laravel? EOL is coming… (Upgrading PHP means changing middleware) (If something happen wrong it would be hard to revert middleware on EC2) (I don't want to do it...) No, I …(Wait!)

Slide 6

Slide 6 text

beginning of project(containerization proposal) 
 my boss me (If we can containerize, it will make changing the middleware easier.) Before upgrading PHP, Why don't we containerize to ECS? It would be hard to revert middleware on EC2. That’s true. Hmm, go ahead. (start the containerized project)

Slide 7

Slide 7 text

content of project 


Slide 8

Slide 8 text

content of project 
 my skill at 2 years ago - 2+ years experience of web development - no experience of building infrastructure(what is container?🤣) - no experience of building CD

Slide 9

Slide 9 text

content of project 
 Steps 1. try running the app on ECS in a testing environment 2. change functions that relies on local files on EC2 3. release service on ECS

Slide 10

Slide 10 text

content of project( 1 step)
 1. try running the app on ECS in a testing environment I understand ECS and AWS through this part - build infra to use Terraform - make dockerfile and push dockerimage to ECR check functions to use web brower

Slide 11

Slide 11 text

content of project( 2 step)
 2. change functions that depended on local environment on EC2 fixing function list - login session - local file → ElastiCache(Redis) - export temporary file storage location - local file → S3 - GCP credential source - local file → ssm parameter - mail service - postfix → sendgrid api

Slide 12

Slide 12 text

content of project( 3 step)
 3. release service on ECS - build ECS for stg/prod enviroment - make CD to use GitHub Actions - use OIDC to get credential - update ECR and restart ECS task - Changed the target group on ALB from EC2 to ECS when it released - migrate batch to use CloudWatch Events - used cron jobs on EC2 - override the CMD command in Dockerfile with 'php artisan' - chose CW Events because the similar way to cron jobs on EC2

Slide 13

Slide 13 text

content of project( feedback)
 feedback this project Functional requestment is not difficult to understand the basics knowledge of infra(AWS) But no functional requestment is a little difficult, because I have no knowledge for them😥 - logs - how to manage and stock some types of logs (to use Fluent Bit) ? - alert conditions is Good? - security - response header include dangerous info? - when we use ECS Exec, how to manage logs of who executed which commands?

Slide 14

Slide 14 text

after project 


Slide 15

Slide 15 text

after project 
 my boss me Congratulations Zakisan, you did it. Thanks boss, I could complete this project with our team. By the way, If possibility…

Slide 16

Slide 16 text

after project 
 my boss me Congratulations Zakisan, you did it. Thanks boss, I could complete this project with our team. By the way, If possibility… Could you move me to an SRE role? !!!!????

Slide 17

Slide 17 text

to be continued... 


Slide 18

Slide 18 text

try new challenges!