Skip to content

Instantly share code, notes, and snippets.

@ZhijieWang
Forked from anonymous/AWS-ECS.md
Last active December 14, 2016 06:52
Show Gist options
  • Save ZhijieWang/f9df4273dc282957b9382270341dd753 to your computer and use it in GitHub Desktop.
Save ZhijieWang/f9df4273dc282957b9382270341dd753 to your computer and use it in GitHub Desktop.
Demystifying AWS ECS -- ECS documentation for the impatient

Task Definition:

A bunch of containers logically bundled together

  • i.e. Nginx + MVC + DB for Traditional stack
  • i.e. service + optional db for Miscroservices

NetWork Mode:

  • Bridge -- Fork the connection on host's network stack, will have individual IP for container

  • Host -- Share same Network connection with host, faster, but forced port mapping

    Longer Version See Network Mode

Post Mapping:

If you want to run multiple instance of the same container, You probably want running all of them at the same port, but at different IP address, but with same port number.

Do not select host mode for network

Do not enable port mapping

If you enable host mode, see above network mode If you enable port mapping, you may run into conflict with host port already in use, either by other services or by another instance of the same instance. Make sure the host part is left empty for port mapping. The container part is necessary, since ECS uses that to define the container instance's port exposure. With no port exposed, you can't use a load balancer.

ECS will let you dig a hole for yourself. You will be able to create a task definition with port mapping and just one container, specify your target instance a service definition with more than 1 instance of that task running. ECS will only run one instance of that task on a cluster of only 1 node. This will work if desired instance count for cluster is set to 2.

Services

It is just as it suggests, a service, a poorly defined term in IT. My understanding, a Service as a Service Oriented Architecture. Bundling all your individual pieces/tasks together, to enable something usable and scalable.

The number of task is the minimal expected amount of tasks running. If the number is not set to 0, you can't delete the service. You have to update the service, set the number to 0, then delete it.

Load Balancing

Make sure your Load Balancer, Load Balancer Target Group and your cluster instances running the cluster is on the same VPC, other wise you will have a silent failure of Error: InvalidTarget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment