@@ -6,6 +6,18 @@ Parameters:
66  QueueId :
77    Description : The QueueID of the Deadline Queue that you are adding a balancer for 
88    Type : String 
9+   BalanceOnJobSubmission :
10+     Description : " Whether or not to trigger the Balancer in response to a Job Submission" 
11+     Type : String 
12+     Default : " true" 
13+     AllowedValues :
14+       - " true" 
15+       - " false" 
16+ 
17+ Conditions :
18+   JobSubmissionTriggersLambda : !Equals 
19+     - !Ref  BalanceOnJobSubmission 
20+     - " true" 
921Resources :
1022  DeadlineWeightedJobBalancer :
1123    Type : AWS::Lambda::Function 
@@ -254,6 +266,65 @@ Resources:
254266      MaximumRetryAttempts : 2 
255267      Qualifier : ' $LATEST' 
256268
269+   DeadlineWeightedJobBalancerSubmissionRule :
270+     Condition : JobSubmissionTriggersLambda 
271+     Type : AWS::Events::Rule 
272+     Properties :
273+       Description : Responds to Job Submissions and balances the Queue 
274+       State : ENABLED 
275+       EventPattern :
276+         source :
277+           - " aws.deadline" 
278+         detail-type :
279+           - " Job Lifecycle Status Change" 
280+       Targets :
281+         - Arn : !GetAtt 
282+             - DeadlineWeightedJobBalancer 
283+             - Arn 
284+           DeadLetterConfig :
285+             Arn : !GetAtt 
286+               - UnprocessedBalancingEventQueue 
287+               - Arn 
288+           RetryPolicy :
289+             MaximumRetryAttempts : 1 
290+           RoleArn : !GetAtt 
291+             - DeadlineWeightedJobBalancerSubmissionRuleRole 
292+             - Arn 
293+   DeadlineWeightedJobBalancerSubmissionRuleRole :
294+     Condition : JobSubmissionTriggersLambda 
295+     Type : ' AWS::IAM::Role' 
296+     Properties :
297+       AssumeRolePolicyDocument :
298+         Version : 2012-10-17 
299+         Statement :
300+           - Effect : Allow 
301+             Principal :
302+               Service :
303+                 - events.amazonaws.com 
304+             Action :
305+               - sts:AssumeRole 
306+             Condition :
307+               StringEquals :
308+                 aws:SourceAccount : !Sub "${AWS::AccountId}" 
309+       Policies :
310+         - PolicyName : Amazon-EventBridge-Rule-Execution-Policy 
311+           PolicyDocument :
312+             Version : ' 2012-10-17' 
313+             Statement :
314+               - Effect : Allow 
315+                 Action :
316+                   - lambda:InvokeFunction 
317+                 Resource :
318+                   - !GetAtt  DeadlineWeightedJobBalancer.Arn 
319+                   - !Sub  " ${DeadlineWeightedJobBalancer.Arn}:*" 
320+               - Effect : Allow 
321+                 Action :
322+                   - sqs:SendMessage 
323+                 Resource :
324+                   - !GetAtt 
325+                     - UnprocessedBalancingEventQueue 
326+                     - Arn 
327+ 
257328  DeadlineWeightedJobBalancerSchedule :
258329    Type : AWS::Scheduler::Schedule 
259330    Properties :
0 commit comments