File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff 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
6675Advanced usage
Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments