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 回答
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.

已回答 1 年前
  • 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.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则