Dockerized script to deploy an ECS service based on cloudformation stacks (while assuming a role to access a sub-account).
It's meant to be used in a CI environment.
Inside the container, run:
ecs-cf-deploy -s $SERVICE -c $CLUSTER -a $ACCOUNT -ar $ROLE -r $AWS_DEFAULT_REGION
An example can be found on the manual-api repo. The AWS credentials will be passed by circleci automatically to the container.
This container is deployed in docker hub.
Currently, all apis are using the image tagged with lastest
.
You can deploy manually by doing this (permissions are required to push on this docker hub repo)
docker build . -t mycs/ecs-cf-deploy
docker push mycs/ecs-cf-deploy
- Assume role on given account
- Get the unique name of the cluster from the output of the cloudformation stack
- Get the service name from the output of the cloudformation stack
- Force a redeployment of the service on the given ecs cluster
- The deployment takes a few minutes as it's waiting for the new tasks to run successfuly before deleting the old ones
If you want to contribute to this repo, feel free to submit a pull request. Here are some ideas if improvement we'd like to have:
- tests (automated on circleci)
- a solution to run this script as a docker container (
docker run -it mycs/ecs-cf-deploy -e ''...
)