Skip to content

Commit 262137e

Browse files
authored
Merge pull request #1 from RoundingWellOS/no-service
No service
2 parents a0099d9 + 16fd5e4 commit 262137e

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ custom:
5252
myArn: #{MyResource.Arn}
5353
cpu: 512 # optional, defaults to 25% -> 256, see cloudformation docs for valid values
5454
memory: 1GB # optional, defaults to 0.5GB
55+
noService: true # optional, defaults to false.
56+
# If set to `true`, will not create ECS service - tasks may then be executed using AWS API via `run-task`instead.
5557
```
5658

5759
Advanced usage

lib/index.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,26 @@ class ServerlessFargateTasks {
110110
let desired = options.tasks[identifier]['desired']
111111

112112
// create the service definition
113-
var service = {
114-
'Type': 'AWS::ECS::Service',
115-
'Properties': Object.assign({
116-
'Cluster': {"Fn::Sub": '${FargateTasksCluster}'},
117-
'LaunchType': 'FARGATE',
118-
'ServiceName': name,
119-
'DesiredCount': desired == undefined ? 1 : desired,
120-
'TaskDefinition': {"Fn::Sub": '${' + normalizedIdentifier + 'Task}'},
121-
'NetworkConfiguration': {
122-
'AwsvpcConfiguration': Object.assign({
123-
'AssignPublicIp': options.vpc['public-ip'] || "DISABLED",
124-
'SecurityGroups': options.vpc['security-groups'] || [],
125-
'Subnets': options.vpc['subnets'] || [],
126-
}, network_override),
127-
}
128-
}, service_override)
113+
if (!options.tasks[identifier].noService) {
114+
const service = {
115+
'Type': 'AWS::ECS::Service',
116+
'Properties': Object.assign({
117+
'Cluster': {"Fn::Sub": '${FargateTasksCluster}'},
118+
'LaunchType': 'FARGATE',
119+
'ServiceName': name,
120+
'DesiredCount': desired == undefined ? 1 : desired,
121+
'TaskDefinition': {"Fn::Sub": '${' + normalizedIdentifier + 'Task}'},
122+
'NetworkConfiguration': {
123+
'AwsvpcConfiguration': Object.assign({
124+
'AssignPublicIp': options.vpc['public-ip'] || "DISABLED",
125+
'SecurityGroups': options.vpc['security-groups'] || [],
126+
'Subnets': options.vpc['subnets'] || [],
127+
}, network_override),
128+
}
129+
}, service_override)
130+
}
131+
template['Resources'][normalizedIdentifier + 'Service'] = service
129132
}
130-
template['Resources'][normalizedIdentifier + 'Service'] = service
131133
});
132134

133135
function yellow(str) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
},
1515
"scripts": {
1616
},
17-
"version": "0.4.1"
17+
"version": "0.5.0"
1818
}

0 commit comments

Comments
 (0)