Skip to content

Instantly share code, notes, and snippets.

@mochizuki-masao
Created July 6, 2017 07:11
Show Gist options
  • Save mochizuki-masao/2ebd1f27359dfb8357e675ed60ed558a to your computer and use it in GitHub Desktop.
Save mochizuki-masao/2ebd1f27359dfb8357e675ed60ed558a to your computer and use it in GitHub Desktop.
generate `docker run` command from AWS ECS TaskDefinition
#!/bin/bash
taskDefinitionName=$1
OPTS=""
definition=$(aws ecs describe-task-definition --task-definition ${taskDefinitionName} | jq '.taskDefinition.containerDefinitions[0]')
image=$(echo $definition | jq -r '.image')
# envvar
OPTS="${OPTS}$(echo $definition | jq -r '.environment[] | "-e \(.name)=\"\(.value)\""' | tr '\n' ' ')"
OPTS="${OPTS}$(echo $definition | jq -r '.portMappings[0] | "-p \(.hostPort):\(.containerPort)"')"
echo "docker run ${OPTS} ${image}"
@mochizuki-masao
Copy link
Author

Usage

$ ./taskdef.sh foo:32

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