Skip to content

Instantly share code, notes, and snippets.

@johnnypez
Last active July 21, 2017 21:12
Show Gist options
  • Save johnnypez/4ca6a7041fd07a53de84d66d4cc830d1 to your computer and use it in GitHub Desktop.
Save johnnypez/4ca6a7041fd07a53de84d66d4cc830d1 to your computer and use it in GitHub Desktop.
Creating and ECS Optimised AMI with Instance Storage

Launch an instance storage backed ec2 instance with the default ECS Optimized AMI (c3.* or m3.* family) Map /dev/xvdcz to ephemeral0

SSH into it

# stop docker processes
docker ps -q | xargs docker stop

# stop docker
sudo service docker stop

# stop ecs
sudo stop ecs

# remove ecs config data
sudo rm -f /var/lib/ecs/data/*.json

# shutdown
sudo shutdown -H now

Then create the image

aws ec2 create-image --instance-id INSTANCE_ID \
  --name custom-ephemeral-amzn-ecs-optimized-2017.03.d \
  --description "custom ecs optimized image with ephemeral docker storage" \
  --block-device-mapping "[{\"DeviceName\": \"/dev/xvdcz\",\"VirtualName\":\"ephemeral0\"}]" \
  --region us-east-1

Spin up a managed cluster using that ami. Make sure that the managed cluster is configured to use only those instance families that support ephemeral storage.

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