Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to skip ECS Service creation #8

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 19 additions & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.tasks[identifier].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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
},
"scripts": {
},
"version": "0.4.1"
"version": "0.5.0"
}