SAM Template How to add tags to a Serverless Function EventBridge Rule Schedule?

0

Hi,

I am using a Cloudformation SAM template to create a Serverless Lambda function and attach a Schedule (see example below). This creates a Lambda function and EventBridge rule resource successfully.

Adding tags for the Lambda function is fine. But I am struggling to work out how to add any tags to the EventBridge rule through this template (either custom tags or CloudFormation stack tags).

Does anyone know whether it is actually possible to add tags for an EventBridge rule via a SAM template?

Thanks!

Resources:
  myServerlessFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: functions/sample/
      Handler: sample.lambdahandler
      Runtime: nodejs16.x
      Architectures:
        - x86_64
      MemorySize: 128
      Timeout: 100
      FunctionName: 'samplefunction'
      Description: A sample lambda function.
      Policies:
        - AWSLambdaBasicExecutionRole

      Tags:
        Env: dev

      Events:
        ScheduledFunction:
          Type: Schedule
          Properties:
            Name: 'sampleschedule'
            Schedule: rate(1 day)
1 Answer
0

Good question. According to this link from the Cloudformation documentation, the AWS::Events:Rule construct that creates the event, only supports tags when created with ECS. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-tag.html - I would assume that when SAM renders the Cloudformation, it will be bound by this same constraint.

answered 12 days ago
  • Thank you for your reply Vinoopal. I suspect your assumption here is most likely correct. Perhaps this functionality will be available for SAM templates in the future.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions