Mappings:
ScheduleExpressions:
us-east-1:
DailySchedule: "cron(0 18 * * ? *)"
us-west-2:
DailySchedule: "cron(0 17 * * ? *)"
Resources:
MyLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Code: ...
Handler: ...
Role: ...
Runtime: ...
Timeout: ...
ScheduleExpression: !FindInMap [ScheduleExpressions, !Ref 'AWS::Region', DailySchedule]
在上面的示例中,“!Ref 'AWS::Region'”将返回当前区域的名称,然后使用“!FindInMap”函数从Mapping中选择正确的ScheduleExpression。