Skip to content

Commit ac80b64

Browse files
authored
Merge pull request #5 from RoundingWellOS/feature/addLoadBalancerSupport
Add support for registering services with load balancers target groups.
2 parents 5cb5430 + fa73750 commit ac80b64

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ custom:
6161
expression: 'cron(0 12 * * ? *)' # See https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html for more options.
6262
task-count: 2
6363
platform-version: 1.4.0 #Defaults to 'LATEST' which is 1.3.0 as of now. 1.3.0 does not support ECS volumes.
64+
65+
# You can register services with Application or Network Load Balancer target groups
66+
my-task-with-load-balancers:
67+
image: 123456789369.dkr.ecr.eu-west-1.amazonaws.com/my-image
68+
loadBalancers:
69+
- port: 8080
70+
arn: ${self:custom.httpTargetGroupArn}
71+
- port 8443
72+
arn: ${self:custom.httpsTargetGroupArn}
6473
```
6574

6675
Advanced usage

lib/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ class ServerlessFargateTasks {
159159
}
160160
}, service_override)
161161
}
162+
// Configure Load Balancers if defined.
163+
if(options.tasks[identifier].hasOwnProperty('loadBalancers')) {
164+
let loadBalancers = [];
165+
options.tasks[identifier]['loadBalancers'].forEach(item => {
166+
const loadBalancer = Object.assign({
167+
'ContainerName': name,
168+
'ContainerPort': item.port,
169+
'TargetGroupArn': item.arn
170+
});
171+
loadBalancers.push(loadBalancer);
172+
});
173+
}
162174
template['Resources'][normalizedIdentifier + 'Service'] = service
163175
}
164176
});

0 commit comments

Comments
 (0)