From a5259e8e2ae22df6eb5aaf9d1d48eb66fbdab0d7 Mon Sep 17 00:00:00 2001 From: Roni Frantchi Date: Mon, 19 Aug 2019 15:46:38 +0300 Subject: [PATCH 1/5] allow to skip service creation --- README.md | 2 ++ lib/index.js | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f9f0126..b0e5e48 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ custom: myArn: #{MyResource.Arn} cpu: 512 # optional, defaults to 25% -> 256, see cloudformation docs for valid values memory: 1GB # optional, defaults to 0.5GB + noService: true # optional, defaults to false. + # If set to `true`, will not create ECS service - tasks may then be executed using AWS API via `run-task`instead. ``` Advanced usage diff --git a/lib/index.js b/lib/index.js index 09a7d38..eda8a74 100644 --- a/lib/index.js +++ b/lib/index.js @@ -110,24 +110,26 @@ class ServerlessFargateTasks { let desired = options.tasks[identifier]['desired'] // create the service definition - var service = { - 'Type': 'AWS::ECS::Service', - 'Properties': Object.assign({ - 'Cluster': {"Fn::Sub": '${FargateTasksCluster}'}, - 'LaunchType': 'FARGATE', - 'ServiceName': name, - 'DesiredCount': desired == undefined ? 1 : desired, - 'TaskDefinition': {"Fn::Sub": '${' + normalizedIdentifier + 'Task}'}, - 'NetworkConfiguration': { - 'AwsvpcConfiguration': Object.assign({ - 'AssignPublicIp': options.vpc['public-ip'] || "DISABLED", - 'SecurityGroups': options.vpc['security-groups'] || [], - 'Subnets': options.vpc['subnets'] || [], - }, network_override), - } - }, service_override) + if (!options.noService) { + const service = { + 'Type': 'AWS::ECS::Service', + 'Properties': Object.assign({ + 'Cluster': {"Fn::Sub": '${FargateTasksCluster}'}, + 'LaunchType': 'FARGATE', + 'ServiceName': name, + 'DesiredCount': desired == undefined ? 1 : desired, + 'TaskDefinition': {"Fn::Sub": '${' + normalizedIdentifier + 'Task}'}, + 'NetworkConfiguration': { + 'AwsvpcConfiguration': Object.assign({ + 'AssignPublicIp': options.vpc['public-ip'] || "DISABLED", + 'SecurityGroups': options.vpc['security-groups'] || [], + 'Subnets': options.vpc['subnets'] || [], + }, network_override), + } + }, service_override) + } + template['Resources'][normalizedIdentifier + 'Service'] = service } - template['Resources'][normalizedIdentifier + 'Service'] = service }); function yellow(str) { From dcc3e66e09c6174b15b9e1777c463faa0d383d49 Mon Sep 17 00:00:00 2001 From: Roni Frantchi Date: Mon, 19 Aug 2019 15:49:28 +0300 Subject: [PATCH 2/5] use the right options --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index eda8a74..6c8c88c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -110,7 +110,7 @@ class ServerlessFargateTasks { let desired = options.tasks[identifier]['desired'] // create the service definition - if (!options.noService) { + if (!options.tasks[identifier]) { const service = { 'Type': 'AWS::ECS::Service', 'Properties': Object.assign({ From e986ec24473bc547122137a096469165abc452ae Mon Sep 17 00:00:00 2001 From: Roni Frantchi Date: Mon, 19 Aug 2019 15:54:34 +0300 Subject: [PATCH 3/5] use the right options --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 6c8c88c..4d07985 100644 --- a/lib/index.js +++ b/lib/index.js @@ -110,7 +110,7 @@ class ServerlessFargateTasks { let desired = options.tasks[identifier]['desired'] // create the service definition - if (!options.tasks[identifier]) { + if (!options.tasks[identifier].noService) { const service = { 'Type': 'AWS::ECS::Service', 'Properties': Object.assign({ From 717a1fc46d82c9c65348ede71da5252ac8a7dc61 Mon Sep 17 00:00:00 2001 From: Roni Frantchi Date: Tue, 20 Aug 2019 15:21:42 +0300 Subject: [PATCH 4/5] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dad206c..e8273fb 100644 --- a/package.json +++ b/package.json @@ -14,5 +14,5 @@ }, "scripts": { }, - "version": "0.4.1" + "version": "0.5" } From 16fd5e4fc631dfb3fac055fe6495df2831072d7f Mon Sep 17 00:00:00 2001 From: Roni Frantchi Date: Tue, 20 Aug 2019 15:25:05 +0300 Subject: [PATCH 5/5] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e8273fb..241e389 100644 --- a/package.json +++ b/package.json @@ -14,5 +14,5 @@ }, "scripts": { }, - "version": "0.5" + "version": "0.5.0" }