This wercker step allows to deploy Docker containers with AWS ECS service or run a task outside of a service.
Please read the AWS ECS documentation and API before using this step.
The step is written in Python 2.7 and use Pip and Boto3 module.
To deploy an application with AWS ECS, the Wercker step follow this steps:
There is two different flows depending if the Wercker step is running in "service mode" or in "task only mode".
If service-name
is provided in the configuration, the service mode is used.
Step Configuring AWS
This initial step consists on configuring AWS.
The following configuration allows to setup this step :
key
(required): AWS Access Key IDsecret
(required): AWS Secret Access Keyregion
(optional): Default region name
Step Checking ECS Cluster
This step check a previously created ECS cluster exists.
The following configuration allows to setup this step :
cluster-name
(required): The name of the cluster to deploy the service
Step Checking ECS Service (Skipped in task only mode)
This step check a previously created ECS service exists. The service MUST be created before using this step.
The following configuration allows to setup this step :
service-name
(optional): The name of the service to deploy
This step register a new task definition for the service.
The following configuration allows to setup this step :
task-definition-name
(required): The name of the task definitiontask-definition-file
(required): The file containing the task definitiontask-definition-volumes-file
(optional): The file containing the task definition volumes
This step downscale the service in order to deploy the new revision.
See this thread for explanation :
The service scheduler will always scale up at least 1 new container before shutting down old containers. This means on an update, if your current service uses all resources in your cluster you may actually need to scale your service to N-1 where N is your current running task count for that service. For example, if you have 5 container instances and 5 tasks running bound to host port 80, in order to perform a rolling update you'll need to set the desired count on the service to 4. The scheduler will recognize that it can stop 1 container and still meet your needs. After stopping 1, the free space will be used to start another. You can think of desired count as also the minimum count for now and the scheduler won't remove tasks below that minimum which is likely why you see resources not found.
This step is run only if the number of tasks running is greater than the following configuration :
minimum-running-tasks
(optional default 2): The minimum number of running tasks expected
Step Update ECS Service
This step update the service with the new revision.
Step Upscale ECS Service
This step upscale the service to the initial number of tasks.
Step Run task
This step run a task on a single node and wait for its completion. The step fail if the task can't be run or if its command exit code is different from 0.
The following example deploy an hello
service on ECS :
deploy:
steps:
- 1science/aws-ecs:
key: aws_access_key_id
secret: aws_access_secret_id
cluster-name: staging
task-definition-name: hello-migrate-db
task-definition-file: /app/hello-migrate-db-task-definition.json
- 1science/aws-ecs:
key: aws_access_key_id
secret: aws_access_secret_id
cluster-name: staging
service-name: hello
task-definition-name: hello
task-definition-file: /app/hello-task-definition.json
task-definition-volumes-file: /app/hello-task-definition-volumes.json