This is a script for easy deployment to Amazon ECS.
- Python 3.4
- Docker
- AWS CLI
Before running this script, you must make sure to log into your Docker image registry and configure the AWS CLI first. Additionally, you must ensure that your AWS ECS agents are able to authenticate themselves against your Docker image registry in case it is private, by adding the following to /etc/ecs/ecs.config and reboot:
ECS_ENGINE_AUTH_TYPE=dockercfg
ECS_ENGINE_AUTH_DATA={"tutum.co":{"auth":"<auth-string>","email":"<my-email>"}}
The script deploy-ecs
deploys to your default ECS cluster. You will need task definition and
service JSON files. For this to work, you should have an elastic load balancer and an idle ECS
instance or ensure that the service's deployment configuration specifies a minimumHealthyPercent
of less than 100, so that ECS always has an extra node to deploy the new task definition to.
Then ECS will update every node one after the other, so that downtime is avoided.
The script implements the following procedure:
- Tag Docker images corresponding to containers in the task definition with the Git revision.
- Push the Docker image tags to the corresponding registries.
- Deregister old task definitions in the task definition family.
- Register new task definition, now referring to Docker images tagged with current Git revisions.
- Update service to use new task definition.