From aabb47eb5755442c3105d8f781e4eb9db3c37b13 Mon Sep 17 00:00:00 2001 From: "Dido (Christoph Poelt)" Date: Tue, 25 Feb 2020 12:40:23 +0100 Subject: [PATCH 1/4] update readme --- README.md | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 4ee282c..c3bb767 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ This will attempt to stop an existing task, making way for the blue/green rollou If you're only running a single task you'll experience some down time. **Use at your own risk.** -#### Usage +## Usage ecs-task-deploy [options] @@ -66,7 +66,7 @@ If you're only running a single task you'll experience some down time. **Use at **Hint: You can pass a service OR a task definition name. If a service is passed that service will be updated, otherwise only the given task definition.** -##### Node +### CLI To run via cli. @@ -87,10 +87,14 @@ ecs-task-deploy \ To run in code. - npm install ecs-task-deploy --save +```sh +npm install @valiton/ecs-task-deploy +``` + +### Node API ```javascript -const ecsTaskDeploy = require('ecs-task-deploy') +const ecsTaskDeploy = require('@valiton/ecs-task-deploy'); ecsTaskDeploy({ awsAccessKey: 'ABCD', @@ -110,26 +114,3 @@ ecsTaskDeploy({ ) ``` -##### Docker - -Run with arguments. - - docker run --rm stead/ecs-task-deploy \ - -k \ - -s \ - -r \ - -c \ - -n \ - -i - -Run with standard AWS environment variables. - - docker run --rm \ - -e AWS_DEFAULT_REGION= \ - -e AWS_ACCESS_KEY_ID= \ - -e AWS_SECRET_ACCESS_KEY= \ - stead/ecs-task-deploy \ - -c \ - -n \ - -i - From 074e6e5675781b65bea1ab92b0d5cfe686413792 Mon Sep 17 00:00:00 2001 From: "Dido (Christoph Poelt)" Date: Tue, 25 Feb 2020 13:07:22 +0100 Subject: [PATCH 2/4] remove deprecated aws-sdk-promise --- package-lock.json | 6 +++--- package.json | 10 ++-------- src/index.js | 18 +++++++++--------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 914c453..a900166 100644 --- a/package-lock.json +++ b/package-lock.json @@ -74,9 +74,9 @@ "integrity": "sha1-sqRdpf36ILBJb8N2jMJ8EvqRan0=" }, "aws-sdk": { - "version": "2.624.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.624.0.tgz", - "integrity": "sha512-6MhbdND7A5lEBiNSZ/HLwhKgrysmwTy6C47H7vfuVnY25hDkIND3C0PLqeRyskUqxv0RqsiAB4kqiMtpE08IGA==", + "version": "2.625.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.625.0.tgz", + "integrity": "sha512-8OoXw5SE/IliSo8q204amuLN46E2g1pGJQjVFTstoiETfaZvRxabL+DzIigJSV8QdybzzETGV3w50jvMfbsJ8A==", "requires": { "buffer": "4.9.1", "events": "1.1.1", diff --git a/package.json b/package.json index c7189fa..321a140 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,7 @@ "keywords": [ "aws", "ecs", - "deploy", - "docker" + "deploy" ], "files": [ "src/" @@ -24,10 +23,6 @@ "bugs": { "url": "https://github.com/valiton/ecs-task-deploy/issues" }, - "engines": { - "node": ">=4.0.0", - "npm": ">=2.14.2" - }, "main": "src/index.js", "bin": { "ecs-task-deploy": "src/run.js" @@ -36,8 +31,7 @@ "lint": "eslint src" }, "dependencies": { - "aws-sdk": "^2.28.0", - "aws-sdk-promise": "0.0.2", + "aws-sdk": "^2.625.0", "chalk": "^1.1.3", "commander": "^2.9.0" }, diff --git a/src/index.js b/src/index.js index acbbcb3..ecaa9fa 100755 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ 'use strict' -const AWS = require('aws-sdk-promise') +const AWS = require('aws-sdk') const assert = require('assert') module.exports = execute @@ -55,7 +55,7 @@ function deployTaskDefinition(options) { function getService(ecs, options) { return ecs.describeServices({ cluster: options.cluster, services: [ options.service ] }).promise() - .then(res => res.data.services.find(service => service.serviceName == options.service)) + .then(res => res.services.find(service => service.serviceName == options.service)) .then(service => { assert.ok(service, `Service ${options.service} not found, aborting.`) return service @@ -64,13 +64,13 @@ function getService(ecs, options) { function getTaskDefinition(ecs, taskDef, options) { if (options.verbose) console.info('get task definition') - return ecs.describeTaskDefinition({ taskDefinition: taskDef }).promise().then(res => res.data.taskDefinition) + return ecs.describeTaskDefinition({ taskDefinition: taskDef }).promise().then(res => res.taskDefinition) } function addNewTaskDefinition(ecs, template, options) { if (options.verbose) console.info(`registering new task definition with image '${options.image.uri}'`) const newTaskDef = newTaskDefinition(template, options) - return ecs.registerTaskDefinition(newTaskDef).promise().then(res => res.data.taskDefinition) + return ecs.registerTaskDefinition(newTaskDef).promise().then(res => res.taskDefinition) } function newTaskDefinition(template, options) { @@ -117,7 +117,7 @@ function parseImagePath(uri) { function updateService(ecs, taskDef, options) { if (options.verbose) console.info(`update service with new task definition '${taskDef.taskDefinitionArn}'`) const serviceOptions = createServiceOptions(taskDef, options) - return ecs.updateService(serviceOptions).promise().then(res => ({ info: res.data.service, taskDef })) + return ecs.updateService(serviceOptions).promise().then(res => ({ info: res.service, taskDef })) } function createServiceOptions(taskDef, options) { @@ -132,8 +132,8 @@ function checkForTaskKill(ecs, service, options) { if (options.killTask) { if (options.verbose) console.info('searching for running task to stop') return ecs.listTasks({ cluster: options.cluster, serviceName: options.service }).promise().then(res => { - if (res.data && res.data.taskArns && res.data.taskArns.length) { - const task = res.data.taskArns[0] + if (res.taskArns && res.taskArns.length) { + const task = res.taskArns[0] if (options.verbose) console.info(`stopping task '${task}'`) return ecs.stopTask({ cluster: options.cluster, task, reason: 'Making room for blue/green deployment' }).promise() .then(() => { @@ -169,13 +169,13 @@ function waitForServiceUpdate(ecs, service, options) { serviceName: service.info.serviceName, desiredStatus: 'RUNNING' }).promise().then(res => { - const tasks = res.data.taskArns || [] + const tasks = res.taskArns || [] if (tasks.length) { ecs.describeTasks({ tasks, cluster: service.info.clusterArn }).promise().then(res => { - const task = res.data.tasks.find(task => task.taskDefinitionArn === service.taskDef.taskDefinitionArn) + const task = res.tasks.find(task => task.taskDefinitionArn === service.taskDef.taskDefinitionArn) if (task) { resolve(task) } else if (Date.now() - START_TIME > MAX_TIMEOUT) { From 70293ab0a54a7861eab0c241d40633678ab6f0a3 Mon Sep 17 00:00:00 2001 From: "Dido (Christoph Poelt)" Date: Tue, 25 Feb 2020 13:14:41 +0100 Subject: [PATCH 3/4] fix bug when deploying a service --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ecaa9fa..ed04a8e 100755 --- a/src/index.js +++ b/src/index.js @@ -46,7 +46,7 @@ function deployTaskDefinition(options) { assert.ok(options.service, 'ECS service name missing') console.info('service given, updating service') return getService(ecs, options) - .then(service => getTaskDefinition(ecs, service, options)) + .then(service => getTaskDefinition(ecs, service.taskDefinition, options)) .then(taskDef => addNewTaskDefinition(ecs, taskDef, options)) .then(taskDef => updateService(ecs, taskDef, options)) .then(service => checkForTaskKill(ecs, service, options)) From 898ca3462ef85b14dc449e19d92af20858249547 Mon Sep 17 00:00:00 2001 From: "Dido (Christoph Poelt)" Date: Tue, 25 Feb 2020 13:16:11 +0100 Subject: [PATCH 4/4] patch version for fix --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a900166..38489cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@valiton/ecs-task-deploy", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 321a140..58dc921 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@valiton/ecs-task-deploy", - "version": "1.4.1", + "version": "1.4.2", "description": "Update an ECS task definition with Docker image and trigger blue/green deployment", "keywords": [ "aws",