mirror of
https://github.com/Sea-Haven-Industries/ring-scheduler-3cx.git
synced 2026-05-18 20:20:12 +00:00
On weekends, the scheduler now runs twice: - 8am: routes calls to the day shift person (checks DynamoDB -DAY keys) - 5pm: switches to the night shift person (existing after-hours logic) Adds two EventBridge rules for weekend 5pm triggers (EST/EDT). DynamoDB keys: OVERRIDE SK=<date>-DAY, WEEKLY SK=Saturday-Day/Sunday-Day.
92 lines
2.9 KiB
YAML
92 lines
2.9 KiB
YAML
AWSTemplateFormatVersion: "2010-09-09"
|
|
Transform: AWS::Serverless-2016-10-31
|
|
Description: 3CX Ring Group After-Hours Scheduler
|
|
|
|
Parameters:
|
|
Timezone:
|
|
Type: String
|
|
Default: "America/New_York"
|
|
ShiftTableName:
|
|
Type: String
|
|
Default: "afterhours-shifts"
|
|
Description: DynamoDB table for Slack shift manager overrides
|
|
|
|
Globals:
|
|
Function:
|
|
Runtime: python3.12
|
|
Timeout: 30
|
|
MemorySize: 128
|
|
|
|
Resources:
|
|
SchedulerFunction:
|
|
Type: AWS::Serverless::Function
|
|
Properties:
|
|
FunctionName: 3cx-ring-group-scheduler
|
|
Handler: src/handler.handler
|
|
CodeUri: .
|
|
Environment:
|
|
Variables:
|
|
SSM_PREFIX: /3cx-scheduler
|
|
TZ: !Ref Timezone
|
|
SHIFT_TABLE: !Ref ShiftTableName
|
|
Policies:
|
|
- Statement:
|
|
- Effect: Allow
|
|
Action:
|
|
- ssm:GetParametersByPath
|
|
- ssm:GetParameter
|
|
- ssm:GetParameters
|
|
Resource:
|
|
- !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/3cx-scheduler"
|
|
- !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/3cx-scheduler/*"
|
|
- Effect: Allow
|
|
Action:
|
|
- kms:Decrypt
|
|
Resource: "*"
|
|
Condition:
|
|
StringEquals:
|
|
"kms:ViaService": !Sub "ssm.${AWS::Region}.amazonaws.com"
|
|
- Effect: Allow
|
|
Action:
|
|
- dynamodb:GetItem
|
|
Resource:
|
|
- !Sub "arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${ShiftTableName}"
|
|
Events:
|
|
# EST: 8am ET = 13:00 UTC (Nov-Mar)
|
|
DailyScheduleEST:
|
|
Type: Schedule
|
|
Properties:
|
|
Schedule: cron(0 13 ? * * *)
|
|
Description: "Update 3CX ring group at 8am EST (Nov-Mar)"
|
|
Enabled: true
|
|
# EDT: 8am ET = 12:00 UTC (Mar-Nov)
|
|
DailyScheduleEDT:
|
|
Type: Schedule
|
|
Properties:
|
|
Schedule: cron(0 12 ? * * *)
|
|
Description: "Update 3CX ring group at 8am EDT (Mar-Nov)"
|
|
Enabled: true
|
|
# Weekend 5pm — switch from day shift to night shift person
|
|
# EST: 5pm ET = 22:00 UTC (Nov-Mar)
|
|
WeekendEveningEST:
|
|
Type: Schedule
|
|
Properties:
|
|
Schedule: cron(0 22 ? * SAT,SUN *)
|
|
Description: "Switch to night shift on weekends at 5pm EST (Nov-Mar)"
|
|
Enabled: true
|
|
# EDT: 5pm ET = 21:00 UTC (Mar-Nov)
|
|
WeekendEveningEDT:
|
|
Type: Schedule
|
|
Properties:
|
|
Schedule: cron(0 21 ? * SAT,SUN *)
|
|
Description: "Switch to night shift on weekends at 5pm EDT (Mar-Nov)"
|
|
Enabled: true
|
|
|
|
# SSM Parameters: create these manually via CLI before deploying.
|
|
# See setup instructions in the deploy section below.
|
|
|
|
Outputs:
|
|
FunctionArn:
|
|
Value: !GetAtt SchedulerFunction.Arn
|
|
FunctionName:
|
|
Value: !Ref SchedulerFunction
|