SERVE YOUR CODE ON EDGE WITH DOCKER AND AWS ECS ANYWHERE

AWS ECS Anywhere and IoT Device Management

Ufuk Dag
3 min readJun 21, 2021
ECS Anywhere and Raspberry Pi 4 Setup

When Amazon’s Elastic Container Service (ECS) first launched in 2014, it enabled an easy and convenient way of deploying and scheduling containers in the AWS ecosystem. Back then, you would run a set of EC2 instances, and ECS would deploy containers to instances based on the size, resources, and placement requirements you specified. Succinctly, It’s a local alternative against Kubernetes, and It’s straightforward.

In 2018, AWS released Fargate, bringing a serverless feel to the platform. You could have ECS run your container without having to manage any infrastructure. It’s a complement of AWS Lambda for serverless architecture.

The next iteration is ECS Anywhere, which allows you to deploy your containers to almost any server. You can deploy to an EC2 instance inside AWS, a virtual machine (VM) in another cloud provider, or even a bare metal server in your private data center, or an IoT device. Best of all, you can control the deployments in the same way you would with EC2 or Fargate.

Why are Container technologies (especially Docker) so crucial for IoT World?

Containers, and containerized software, are currently changing the way that IT is deployed on essentially all platforms, whether it’s in the datacenter or in IoT. The idea behind containers is to collect all the tools and libraries necessary to run a specific piece of software, and then isolating that software from the rest of the system. Because containers are not full-on virtual machines, they’re efficient, and Docker is a leader in making containers easy to work with and share with others.

When it comes to IoT, containerized software has the capacity to provide easier development and better security. Because one can package all of the dependencies to run a piece of IoT software into a container, it’s easier to deploy them to a variety of IoT hardware devices.

Let’s start with registering a Raspberry Pi 4 Device To ECS Anywhere

I will use a Raspberry Pi 4 and I installed Ubuntu 20.04 as an operating system.

First, in order for your devices to run Docker and Amazon ECS tasks, you must enable memory cgroups in the boot config. This may not be enabled by default, but it is necessary for Docker to function properly when you set hard or soft memory limits in your Amazon ECS task definition. You can do this by adding cgroup_enable=memory to the file /boot/firmware/cmdline.txt.

Create a new ECS cluster

After creation progress, go to the “Instances” tab into the cluster and click on the “Register External Instances” button.

Register your Raspberry Pi device

You will generate a registration code to register your device to the related cluster. You can change your parameters with your own needed. Copy your registration code and paste it into the Raspberry Pi terminal. It will install ECS and SSM agents.

Copy your code and paste it into Raspberry Pi Terminal

Now you can see your instance on your cluster page, and also, you can connect your devices using the Fleet Manager page.

Open remote connection into your device

Deploy a container with ECS Anywhere

This is the end of the topic today, but I will share different experiences. If you don’t run any task or service ECS before, It will take a little time but not too hard.

--

--

Ufuk Dag

Founder @Plugger.ai, ex-Getir, ex-Insider. Productivity researcher.