Creating ECS Service - Hands OnΒΆ
In order to launch a service, first we need to create an ECS task definition.
We are going to use nginxdemos/hello
image for the container.
For the environment, we can choose whether to run it on Fargate or EC2 instances. We can also choose the OS, CPU, Memory, Role, Network.
We can configure storage - how much storage do we need or adding volumes.
We can also configure monitoring and logging.
Next we want to run this task definition as a service behind a load balancer. For that to work, we need to define 2 security groups.
One that allows the load balancer to connect to the port 80.
And one for the ECS task.
Now we can open up the ECS cluster, open up our demo-cluster and click on deploy.
We are also going to use a Load Balancer.
For the networking - we are going to use a nginx-demo-sg security group.
We are going to modify the ALB, and set the alb-ecs-sg security group for it.
Now we see that the task is running:
If we open up the ALB url:
Now we can open up our service, click on edit and scale it up:
We'll see them provisioning.
And if we refresh the ALB url, we'll see different IDs.