{"id":16596503,"url":"https://github.com/mikestead/ecs-task-deploy","last_synced_at":"2025-03-21T13:32:20.361Z","repository":{"id":3815931,"uuid":"50915981","full_name":"mikestead/ecs-task-deploy","owner":"mikestead","description":"Update an AWS ECS task definition with Docker image and trigger a blue/green deployment","archived":false,"fork":false,"pushed_at":"2023-08-01T14:28:37.000Z","size":101,"stargazers_count":38,"open_issues_count":6,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T23:53:32.369Z","etag":null,"topics":["aws","aws-ecs","continuous-deployment","deployment","docker"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikestead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-02T11:29:22.000Z","updated_at":"2024-10-03T19:46:44.000Z","dependencies_parsed_at":"2023-01-13T12:46:01.481Z","dependency_job_id":null,"html_url":"https://github.com/mikestead/ecs-task-deploy","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikestead%2Fecs-task-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikestead%2Fecs-task-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikestead%2Fecs-task-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikestead%2Fecs-task-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikestead","download_url":"https://codeload.github.com/mikestead/ecs-task-deploy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221815730,"owners_count":16885213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-ecs","continuous-deployment","deployment","docker"],"created_at":"2024-10-11T23:53:27.245Z","updated_at":"2024-10-28T10:13:46.687Z","avatar_url":"https://github.com/mikestead.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ECS Task Deploy\n\n[![Build Status](https://travis-ci.org/mikestead/ecs-task-deploy.svg?branch=greenkeeper%2Fcommander-2.10.0)](https://travis-ci.org/mikestead/ecs-task-deploy)\n\nA script to increment an active task definition on [ECS](https://aws.amazon.com/ecs) with an updated Docker image, followed by a service update to use it.\n\nSequence of steps performed by the script:\n\n1. Download the active task definition of an ECS service.\n1. Clone it.\n1. Given the Docker image name provided, find *any* containers in the task definition with references to it and replace them with the new one. Docker tags are ignored when searching for a match.\n1. Register this new task definition with ECS.\n1. Update the service to use this new task definition, triggering a blue/green deployment.\n\n#### Environment Varaiables\n\nFor all the container definitions found when looking up your defined `image`, you have the option to add or update environment variables for these.\n\nThis can be done using the `--env` option.\n\n    --env \"SERVICE_URL=http://api.somedomain.com\"\n\nYou can supply as many of these as required.\n\n#### Spare Capacity\n\nIn order to roll a blue/green deployment there must be spare capacity available to spin up a task based on your updated task definition.\nIf there's not capacity to do this your deployment will fail.\n\nThis can be done via ECS service `minimum healthy percent` but as a brute force option this tool supports `--kill-task`.\nThis will attempt to stop an existing task, making way for the blue/green rollout.\n\nIf you're only running a single task you'll experience some down time. **Use at your own risk.**\n\n#### Usage\n\n    ecs-task-deploy [options]\n\n    Options:\n\n    -h, --help                output usage information\n    -V, --version             output the version number\n    -k, --aws-access-key \u003ck\u003e  aws access key, or via AWS_ACCESS_KEY_ID env variable\n    -s, --aws-secret-key \u003ck\u003e  aws secret key, or via AWS_SECRET_ACCESS_KEY env variable\n    -r, --region \u003cr\u003e          aws region, or via AWS_DEFAULT_REGION env variable.\n    -c, --cluster \u003cc\u003e         ecs cluster, or via AWS_ECS_CLUSTER env variable\n    -n, --service \u003cn\u003e         ecs service, or via AWS_ECS_SERVICE_NAME env variable\n    -i, --image \u003ci\u003e           docker image for task definition, or via AWS_ECS_TASK_IMAGE env variable\n    -t, --timeout \u003ct\u003e         max timeout (sec) for ECS service to launch new task, defaults to 90s\n    -v, --verbose             enable verbose mode\n    -e, --env \u003ce\u003e             environment variable in \"\u003ckey\u003e=\u003cvalue\u003e\" format  \n    --kill-task               stop a running task to allow space for a rolling blue/green deployment\n\n##### Node\n\nTo run via cli.\n\n    npm install -g ecs-task-deploy\n    \n```javascript\necs-task-deploy \\\n    -k 'ABCD' \\\n    -s 'SECRET' \\\n    -r 'us-west-1' \\\n    -c 'qa' \\\n    -n 'website-service' \\\n    -i '44444444.ddd.ecr.us-east-1.amazonaws.com/website:1.0.2' \\\n    -e 'SERVICE_URL=http://api.somedomain.com' \\\n    -e 'API_KEY=clientapikey' \\\n    -v\n```\n\nTo run in code.\n\n    npm install ecs-task-deploy --save\n\n```javascript\nconst ecsTaskDeploy = require('ecs-task-deploy')\n\necsTaskDeploy({\n  awsAccessKey: 'ABCD',\n  awsSecretKey: 'SECRET',\n  region: 'us-east-1',\n  cluster: 'cache-cluster',\n  service: 'cache-service',\n  image: 'redis:2.8',\n  env: {\n    SERVICE_URL: 'http://api.somedomain.com',\n    API_KEY: 'clientapikey'\n  }\n})\n.then(\n  newTask =\u003e console.info(`Task '${newTask.taskDefinitionArn}' created and deployed`), \n  e =\u003e console.error(e)\n)\n```\n\n##### Docker\n\nRun with arguments.\n\n    docker run --rm stead/ecs-task-deploy \\\n        -k \u003ckey\u003e \\\n        -s \u003csecret\u003e \\\n        -r \u003cregion\u003e \\\n        -c \u003ccluster\u003e \\\n        -n \u003cservice-name\u003e \\\n        -i \u003cimage-name\u003e\n\nRun with standard AWS environment variables.\n\n    docker run --rm \\\n        -e AWS_DEFAULT_REGION=\u003cregion\u003e  \\\n        -e AWS_ACCESS_KEY_ID=\u003ckey\u003e \\\n        -e AWS_SECRET_ACCESS_KEY=\u003csecret\u003e  \\\n        stead/ecs-task-deploy \\\n        -c \u003ccluster\u003e \\\n        -n \u003cservice-name\u003e \\\n        -i \u003cimage-name\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikestead%2Fecs-task-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikestead%2Fecs-task-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikestead%2Fecs-task-deploy/lists"}