Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
feafc38
allow task execution role arn in new task definition
Jun 18, 2019
d4c705a
remove yarn add package-lock
Feb 24, 2020
076e871
kick travis file
Feb 24, 2020
8c2dac6
implement logic for updating task definition without attached service…
Feb 24, 2020
040bb71
fix cli flag and add section in readme
Feb 24, 2020
342635c
small typo fix
Feb 24, 2020
b48ca23
add files prop to package.json, update readme
Feb 24, 2020
5e8a736
update README
Feb 24, 2020
0a6ae44
bump version
Feb 24, 2020
f2c6810
Merge pull request #1 from valiton/add-support-for-task-definition-up…
ChristophP Feb 24, 2020
f8a2f3a
add github action for publishing
Feb 25, 2020
9367055
change npm token env var name
Feb 25, 2020
97db4f8
Merge pull request #2 from valiton/add-publishing-action
hereandnow Feb 25, 2020
b6dae32
make npm package public not scoped
Feb 25, 2020
c30cc10
bump version
Feb 25, 2020
aabb47e
update readme
Feb 25, 2020
074e6e5
remove deprecated aws-sdk-promise
Feb 25, 2020
70293ab
fix bug when deploying a service
Feb 25, 2020
898ca34
patch version for fix
Feb 25, 2020
ab4548a
Merge pull request #3 from valiton/fix-some-issues
hereandnow Feb 25, 2020
6189280
added use-latest-task-definition option + updated dependencies
Jul 14, 2023
be62f62
updated version
Jul 14, 2023
54e64f4
Merge pull request #4 from valiton/add-use-latest-task-definition-option
XDDDaniel Jul 24, 2023
681732a
added manual trigger
Aug 1, 2023
aa8beaf
reverted commit + updated node
Aug 1, 2023
4402988
updated dependencies
Aug 1, 2023
0f20d52
adapted curly brackets
Aug 1, 2023
941fbe2
small adaption
Aug 1, 2023
9ebc35b
Merge pull request #5 from valiton/fix-action
XDDDaniel Aug 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "eslint:recommended",
"ecmaFeatures": {
"modules": true
},
"env": {
"node": true,
"es6": true
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm run lint

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

63 changes: 30 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# ECS Task Deploy

[![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)

A 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.

Originally forked from [`mikestead/ecs-task-deploy`](https://github.com/mikestead/ecs-task-deploy) and extended with
the following features:
- preserves `exetutionRoleArn`s in task definitions(was previously stripped out)
- allows updating stand-alone task-definitions without service

## What does it do?

Sequence of steps performed by the script:

1. Download the active task definition of an ECS service.
Expand All @@ -12,7 +17,13 @@ Sequence of steps performed by the script:
1. Register this new task definition with ECS.
1. Update the service to use this new task definition, triggering a blue/green deployment.

#### Environment Varaiables
## How to use

```sh
npm i @valiton/ecs-task-deploy
```

### Environment Varaiables

For all the container definitions found when looking up your defined `image`, you have the option to add or update environment variables for these.

Expand All @@ -22,7 +33,7 @@ This can be done using the `--env` option.

You can supply as many of these as required.

#### Spare Capacity
## Spare Capacity

In order to roll a blue/green deployment there must be spare capacity available to spin up a task based on your updated task definition.
If there's not capacity to do this your deployment will fail.
Expand All @@ -32,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]

Expand All @@ -45,18 +56,22 @@ If you're only running a single task you'll experience some down time. **Use at
-r, --region <r> aws region, or via AWS_DEFAULT_REGION env variable.
-c, --cluster <c> ecs cluster, or via AWS_ECS_CLUSTER env variable
-n, --service <n> ecs service, or via AWS_ECS_SERVICE_NAME env variable
-d, --task-def <d> task definition name, only needed when service and cluster are not given. can be defined via AWS_ECS_TASK_DEF env variable
-i, --image <i> docker image for task definition, or via AWS_ECS_TASK_IMAGE env variable
-t, --timeout <t> max timeout (sec) for ECS service to launch new task, defaults to 90s
-v, --verbose enable verbose mode
-e, --env <e> environment variable in "<key>=<value>" format
-e, --env <e> environment variable in "<key>=<value>" format
--kill-task stop a running task to allow space for a rolling blue/green deployment

##### Node
**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.**

### CLI

To run via cli.

npm install -g ecs-task-deploy

```javascript
ecs-task-deploy \
-k 'ABCD' \
Expand All @@ -72,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',
Expand All @@ -90,30 +109,8 @@ ecsTaskDeploy({
}
})
.then(
newTask => console.info(`Task '${newTask.taskDefinitionArn}' created and deployed`),
newTask => console.info(`Task '${newTask.taskDefinitionArn}' created and deployed`),
e => console.error(e)
)
```

##### Docker

Run with arguments.

docker run --rm stead/ecs-task-deploy \
-k <key> \
-s <secret> \
-r <region> \
-c <cluster> \
-n <service-name> \
-i <image-name>

Run with standard AWS environment variables.

docker run --rm \
-e AWS_DEFAULT_REGION=<region> \
-e AWS_ACCESS_KEY_ID=<key> \
-e AWS_SECRET_ACCESS_KEY=<secret> \
stead/ecs-task-deploy \
-c <cluster> \
-n <service-name> \
-i <image-name>
Loading