Single Instance ECS Setup

This article describes how you can set up Amazon’s EC2 Container Service (ECS) with only a single instance. ECS lets you run applications packaged in Docker containers on a managed cluster of EC2 instances.

Single Instance & Cluster?

The word “cluster” implies having multiple instances, so why would you want to have a single instance? Your application or service might not have high traffic load. In the world of microservices that can easily be the case. One instance is enough.

I strongly recommend using ECS if your application, or even parts of it, is running on Docker. Unlike an EC2 instance where you set up Docker yourself, ECS gives you an API and the ability to program your infrastructure. And since this is a single instance you do not have to pay for the AutoScaler or LoadBalancer.

People far smarter than me have said it many times: all regular tasks in the production environment must be automated. As with any other application code, you should also put it under version control.


You require valid AWS account credentials and the AWS CLI before you can set up an ECS instance. If you haven’t installed it, you can easily run it with Docker by:

That’s quite handy and I advise you to put it as an alias in your ~/.bashrc.

Commands to set up and run

You should find yourself now within the aws cli and can boot up a Grafana instance using the following:

Please note the “sleep 5” command. It is required since there seem to be some asynchronous processes in place.

Accessing the instance

By now Grafana should be up and running. You have created an ECS cluster called “single-cluster” along an IAM policy that allows EC2 instances to register themselves to the cluster. The Grafana container is registered as a task and the cluster has a service that runs that task.

You can request the public DNS of the instance by:

Commands to clean up

To remove everything you’ve setup before, simply run the following commands within the AWS CLI:


Leave a Reply