Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
85 changes: 44 additions & 41 deletions bin/ecs-service-image-updater
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,52 @@

const updater = require('../');

const argv = require('yargs')
.describe('image', 'Docker image and tag')
.describe('container-name', 'Container to update in the ECS Task Definition. Conflicts with container-names.')
.describe('container-names', 'List of containers to update in the ECS Task Definition. Comma separated. Conflicts with container-name.')
.describe('service-name', 'ECS Service to update')
.describe('task-definition-family', 'Task Definition Family create the new Task Definition in')
.describe('cluster-arn', 'Arn of the ECS Cluster for which the Service exists on. Used in conjunction with service-name')
.describe('output-arn-only', 'Output the new Task Definition Arn only')
.demand(['image'])
.implies('service-name', 'cluster-arn')
.conflicts('container-name', 'container-names')
.conflicts('service-name', 'task-definition-family')
.conflicts('task-definition-family', 'service-name')
.coerce('container-names', function (arg) {
return arg.split(',');
})
.argv;
(async () => {
const yargs = (await import('yargs')).default;
const argv = yargs(process.argv.slice(2))
.describe('image', 'Docker image and tag')
.describe('container-name', 'Container to update in the ECS Task Definition. Conflicts with container-names.')
.describe('container-names', 'List of containers to update in the ECS Task Definition. Comma separated. Conflicts with container-name.')
.describe('service-name', 'ECS Service to update')
.describe('task-definition-family', 'Task Definition Family create the new Task Definition in')
.describe('cluster-arn', 'Arn of the ECS Cluster for which the Service exists on. Used in conjunction with service-name')
.describe('output-arn-only', 'Output the new Task Definition Arn only')
.demand(['image'])
.implies('service-name', 'cluster-arn')
.conflicts('container-name', 'container-names')
.conflicts('service-name', 'task-definition-family')
.conflicts('task-definition-family', 'service-name')
.coerce('container-names', function (arg) {
return arg.split(',');
})
.argv;

const options = {
clusterArn: argv.clusterArn,
containerNames: argv.containerNames,
image: argv.image
}
const options = {
clusterArn: argv.clusterArn,
containerNames: argv.containerNames,
image: argv.image
}

if (argv.containerName) options.containerNames = [argv.containerName];
if (argv.serviceName) options.serviceName = argv.serviceName;
if (argv.taskDefinitionFamily) options.taskDefinitionFamily = argv.taskDefinitionFamily;
if (argv.containerName) options.containerNames = [argv.containerName];
if (argv.serviceName) options.serviceName = argv.serviceName;
if (argv.taskDefinitionFamily) options.taskDefinitionFamily = argv.taskDefinitionFamily;

updater(options)
.then((taskDefinitionArn) => {
if (argv.outputArnOnly) {
console.log(taskDefinitionArn);
return;
}
updater(options)
.then((taskDefinitionArn) => {
if (argv.outputArnOnly) {
console.log(taskDefinitionArn);
return;
}

console.log(`Created Task Definition: ${taskDefinitionArn}`);
console.log(`Created Task Definition: ${taskDefinitionArn}`);

if (argv.serviceName) {
console.log(`Service ${argv.serviceName} has been updated to use the new Task Definition`);
return;
}
})
.catch((err) => {
console.log(err.toString());
process.exit(1);
});
if (argv.serviceName) {
console.log(`Service ${argv.serviceName} has been updated to use the new Task Definition`);
return;
}
})
.catch((err) => {
console.log(err.toString());
process.exit(1);
});
})();
Loading
Loading