0

I'm unable to attach an EventBridge Schedule to a lambda function in AWS SAM.

Here is the section of my SAM template that intends to attach a schedule to the Lambda function:

TestLambda:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: TestLambda
      CodeUri: test_directory/
      Handler: test_file.lambda_handler
      Runtime: python3.8
      Role: !Ref LambdaApiRole
      Events:
        TestLambdaCron:
          Type: Schedule
          Properties:
            Schedule: rate(1 day)

This is the error I get while deploying the template:

Embedded stack <stack ARN> was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to create: [TestLambdaTestLambdaCron].

A solution would be much appreciated, thanks in advance!

PS: LambdaApiRole is defined in the template and can be referenced in the function (working fine), it's when TestLambdaCron is added when the issues occur

The AWS SAM CLI version I am working on is: SAM CLI, version 1.37.0

Rohith
  • 87
  • 1
  • 7

1 Answers1

1

Here is simple template that I have it and it works.

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
  Sample SAM Template for demo

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3

Resources:
  TestFunctionLambda:
    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: app/
      Handler: app.lambda_handler
      Runtime: python3.9
      Architectures:
        - x86_64
      Role: arn:aws:iam::631249183025:role/mycstomrole
      Events:
        CWSchedule:
          Type: Schedule
          Properties:
            Schedule: "rate(1 minute)"
            Name: TestSchedule
            Description: test schedule
            Enabled: true
Sasho Ristovski
  • 147
  • 1
  • 7