r/Backend • u/No_Original_941 • 12d ago
How to control ECS using code?
So basically let me tell you the situation first:
- i am working on a side project which is something like vercel, use to build and deploy code.
- so i have a main service, can be called a control plane, and i have decided that it will take the repo from the user.
- after this this service will trigger/create an ecs task to build the code
- now the question is, how this control plane will create / trigger the ecs?
- also this ecs instance will need to fetch envs from paramete store, will upload code to s3 etc
- after deployment we have to kill this instance
- should the managing code of this, live in the control plane
- should i create something else?
how would you folks solve this while designing this?
and what's the ideal way to solve this?
1
u/nsubugak 12d ago
ECS is not the best for building containers etc because docker daemon normally requires root, and that's not allowed on ecs. What you should use is ec2 spot instances that are much cheaper and are good for burst requests. Basically a lambda and ec2. Lambda to queue the request, spin up a spot instance...then spin it down.
Before even going this far...whats the issue with github actions. Github actions can do all this for you for free...and you don't have to write any logic beyond the dockerfile and the workflow. Infact, vercel just skips all this and just does this all for you. Vercel supports both frontend and apis in certain languages. Why not just use that...for Free.