Skip to content

Instantly share code, notes, and snippets.

@epappas
Created May 6, 2021 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epappas/d780734d302158ff05477a5f11ebec49 to your computer and use it in GitHub Desktop.
Save epappas/d780734d302158ff05477a5f11ebec49 to your computer and use it in GitHub Desktop.
A simple script to convert ecs tasks to docker-compose for better understanding.
#!/usr/bin/env bash
#
# This is a free to use, free to restribute,
# free to fork and free to edit software.
#
# No responsibility is granted for its use
#
# Contributors:
# - Evangelos Pappas <epappas@evalonlabs.com>
#
# Enjoy!
set -euo pipefail
PROFILE=""
REGION=""
TASK=""
for i in "$@"; do
case $i in
help)
echo "ecs2compose [--profile=name] [--region=name] <task_name>"
exit 0
;;
--debug)
set -x
shift
;;
-p=*|--profile=*)
PROFILE="--profile ${i#*=}"
shift
;;
-r=*|--region=*)
REGION="--region ${i#*=}"
shift
;;
*)
TASK="${i}"
;;
esac
done
aws ecs describe-task-definition \
--task-definition ${TASK} \
--query taskDefinition \
${PROFILE} ${REGION} | \
docker run --rm -i micahhausler/container-transform \
--input-type ecs --output-type compose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment