Last active
January 6, 2016 04:56
-
-
Save robbyt/0a65e7552b85bcfab258 to your computer and use it in GitHub Desktop.
Update the ECS agent from ElasticBeanstalk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"commands": { | |
"01ecsupdate": {"command": ".os-config/scripts/ecs-agent-update.sh"}, | |
"99completed": {"command": "logger -t update-ecs-agent completed"} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install this to .os-config/scripts/ecs-agent-update.sh | |
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