Skip to content

Instantly share code, notes, and snippets.

@robbyt
Created January 4, 2016 20:35
Show Gist options
  • Save robbyt/17b13fbe3e5fd467444d to your computer and use it in GitHub Desktop.
Save robbyt/17b13fbe3e5fd467444d to your computer and use it in GitHub Desktop.
#!/bin/bash
ECS_INIT_VER=`curl -sS http://localhost:51678/v1/metadata | jq -r .Version`
echo $ECS_INIT_VER | grep '1.6.0'
if [ $? -eq 0 ]
then
echo "Found outdated version of ECS agent"
NEEDS_UPDATE=1
else
echo "ECS agent is newer than 1.6.0"
NEEDS_UPDATE=0
fi
if [ $NEEDS_UPDATE -eq 1 ]
then
EB_CONFIG_ECS_CLUSTER=`/opt/elasticbeanstalk/bin/get-config container -k ecs_cluster`
CONTAINER_ID=`curl -sS http://localhost:51678/v1/metadata | jq -r .ContainerInstanceArn`
echo "Starting ECS agent update..."
aws ecs update-container-agent --cluster $EB_CONFIG_ECS_CLUSTER --container-instance $CONTAINER_ID
echo "ECS agent update has started, goodbye."
exit 0
else
echo "Not updating ECS agent, goodbye."
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment