Johann8
Johann8

Reputation: 730

Terraform: Deploying a Docker Compose app on EKS/ECS

TL;DR

I use an open-source server application running on Docker Compose. It has a few services, including PostgreSQL DB and Redis.

How can I best deploy this application to AWS in full IaC with Terraform?


Solutions so far

1. AWS ecs-cli

ecs-cli now supports sending docker compose configs in Amazon ECS.

However, I do not think it could be integrated with the Terraform workflow (which is maybe not a big fuss). What I know for sure is that ecs-cli is not supported in CloudFormation, as per this issue, still open at this time. So I assume it cannot easily be added to Terraform either.

2. The hard EKS way

But that is not fully IaC yet. And you have to retranslate your config each time the docker-compose changes in the source repository. And it sounds like a lot of work.

3. Using a Helm chart

4. [Not OK] k8s Kompose

I read Kompose can automagically translate a Docker Compose configuration to a k8s configuration, but they don't appear to be ported on AWS, not to talk about Terraform.

5. [Not OK] The dirty AMI solution

That would kind of hurt: long builds, difficult monitoring, no scaling.

Side notes

Upvotes: 14

Views: 8433

Answers (1)

Johann8
Johann8

Reputation: 730

1. Wait and See

Who knows, ecs-cli-v2 might be better integrated with CloudFormation and/or Terraform.

2. Use a Helm chart

As mentioned in the question. Probably the best solution, albeit requiring a (little) effort to parametrize Helm.

See also: Getting started with Helm.

3. Docker Swarm + CloudFormation + Terraform

Docker Swarm now accepts inputs from a docker-compose.yml file. The template can be found and configured here. Once configured, it may be integrated to a Terraform infrastructure.

This (3-year old) tutorial explains how to use Docker Swarm mode on AWS.

To launch the container, if necessary (not fully investigated, feedback is welcome), you could use Terraform's local-exec. This way you can SSH into the master node and run docker stack deploy and other similar commands, while still having all written down in IaC style.

Upvotes: 6

Related Questions