ring-scheduler-3cx/template.yaml
Adam Moussa cb5817ce95 Fix module import, IAM permissions, and add manual test support
- Fix three_cx_client import path for Lambda packaging
- Expand SSM policy to include parent path and KMS decrypt for SecureString
- Add force flag to bypass 8am schedule check for manual invocations
- Add override_extension payload option for ad-hoc testing
- Update .gitignore for output.json and .DS_Store

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 17:40:58 -04:00

67 lines
1.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"
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
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"
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
# 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