> For the complete documentation index, see [llms.txt](https://tricks.bodik.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tricks.bodik.tech/infrastructure/aws/sam/adding-a-scheduled-timer-to-start-lambda-function-resource-using-sam.md).

# Adding a scheduled timer to start Lambda function resource using SAM

An example of how to add a scheduled timer to start the Lambda function in template.yaml of your SAM configuration

```yaml
YourLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Description: Description of your function
      Runtime: nodejs16.x
      Architectures:
        - x86_64
      Handler: index.handler
      Events:
        CloudWatchEvent:
          Type: Schedule
          Properties:
            Schedule: rate(6 hours)
      MemorySize: 128
      Timeout: 100
```

With this example Lambda function will be executed every 6 hours.&#x20;

More info on the available properties for the Lambda function creation is here. I use CDK documentation, as I have not found related to SAM resources.

{% embed url="<https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-lambda.Function.html>" %}
