AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > Simple stack that uses EventBridge schedules to trigger a lambda function. # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst Globals: Function: Timeout: 3 Resources: ScheduledLambdaFunction: Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction Properties: CodeUri: functions/ Handler: app.lambdaHandler Runtime: nodejs16.x Architectures: - x86_64 Metadata: # Manage esbuild properties BuildMethod: esbuild BuildProperties: Minify: true Target: 'es2020' # Sourcemap: true # Enabling source maps will create the required NODE_OPTIONS environment variables on your lambda function during sam build EntryPoints: - app.ts MyFirstSchedule: Type: AWS::Scheduler::Schedule Properties: Name: 'MySchedule' ScheduleExpression: 'rate(5 minute)' FlexibleTimeWindow: Mode: 'OFF' Target: Arn: !GetAtt ScheduledLambdaFunction.Arn RoleArn: !GetAtt MyFirstScheduleRole.Arn MyFirstScheduleRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - scheduler.amazonaws.com Action: - sts:AssumeRole Policies: - PolicyName: MyFirstScheduleRolePolicy PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: - 'lambda:InvokeFunction' Resource: - !GetAtt ScheduledLambdaFunction.Arn