[editing] AWS ECS Guide
Last updated
Was this helpful?
Last updated
Was this helpful?
Amazon Elastic Container Service
Highly secure, reliable, and scalable way to run containers
ECS - Fargate / EC2
create cluster
create task
create service
there is three options.
in this case we will use Networking only
for make task you might ben need custom roles for smooth.
you can make custom roles in IAM
check this page
after then create task
highly recommend create Fargate task
if you make based on Fargate task you will use awsvpc
network mode
if you select EC2 task you can use bridge
network mode
bridge network
is support custom port mapping
As a result, you should use LoadBalancer with Classic Load Balancer.
you can set Task size
option whatever you want
after that you will make container. and that containers share this task capacity
that means you can run multiple container in one task.
click the Add Container
buttons
in here you should put Container name
and Image
Container name
could be anything this case we will put name as test-container
but Image
should be specific in ECR
when Docker image build in AWS Codebuild
you must put ECR
repository.
and here Task Container pulling that image.
if you made Repository name as test
URI might be ${YOUR_AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/test
so in Image
section we will put lastet
tag together
${YOUR_AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/test:latest
yes you can put other tags. but in previous Article
we built use latest
tag
in here you can put the key name as TEST
and click select and choose ValueFrom
and put this
arn:aws:ssm:${region}:${aws_account_id}:parameter/${parameter_name}
e.g
if you made test variable in Parameter Store
name as /firstDepth/value
in us-east-1
region
it will be like this
arn:aws:ssm:us-east-1:${aws_account_id}:parameter/firstDepth/value
if your ID is 1234 it should be
arn:aws:ssm:us-east-1:1234:parameter/firstDepth/value
now put the Variable like this.
Key
Type
value
TEST
ValueFrom
arn:aws:ssm:us-east-1:1234:parameter/firstDepth/value
Refs: https://docs.aws.amazon.com/AmazonECS/latest/userguide/task_definition_parameters.html
don't use 100% CPU units. that's probably not gonna work
for this you have to make
Clusters
andTask
go AWS ECS -> Clusters -> Create Cluster
or use legacy.
Fargate - Run containers without managing servers or clusters
EC2 -
prerequisite - VPC - Subnets (VPC -> Subnets) - Security groups (optional / can create just in time) VPC -> Security -> Security groups
put VPC, Subnets, Security groups you can create these things in this link
I was create
all
Subnets in same zone and addedall
subnet for 100% coverage. up to you
create LB(load balancer) in EC2 -> LOAD BALANCING -> Load Balancers
there are support three different types
for HTTP & HTTPS
if you made Fargate task you will use ALB
for TCP / TLS / UDP
if you made EC2 task you will use CLB
when create task should select Network Mode. for Fargate awsvpc is normal.
According to AWS guide
Host port mappings are not valid when the network mode for a task definition is host or awsvpc. To specify different host and container port mappings, choose the Bridge network mode.
https://console.aws.amazon.com/ec2
you can set Auto Scaling now but you can do it later
ECS -> Amazon ECS -> Clusters -> your cluster -> your Service -> Update
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html
pass.