AWS Lambda scheduled event source via cloudformation

后端 未结 7 1161
猫巷女王i
猫巷女王i 2021-02-01 02:37

I already have my lambda / roles defined in cloudformation and would love to also use it to add a scheduled eventsources ... are there any docs or examples around ?

相关标签:
7条回答
  • If you use function name as

    "FunctionName": {
          "Fn::GetAtt": [
            "TagWatcherFunction",
            "Arn"
          ]
        }
    

    and you not specify the function then it'll throw you "Template is not valid: Template error: instance of Fn::GetAtt references undefined resource TagWatcherFunction"

    So instead of function name you can directly specify the "lambda ARN". you can see example below

    "TagWatcherRule": {
      "Type": "AWS::Events::Rule",
      "Properties": {
        "ScheduleExpression": "rate(10 minutes)",
        "Targets": [
          {
            "Id": "TagWatcherScheduler",
            "Arn": {
              "Fn::GetAtt": [
                "TagWatcherFunction",
                "Arn"
              ]
            }
          }
        ]
      }
    },
    // role may call the lambda
    "InvokeLambdaPermission": {
      "Type": "AWS::Lambda::Permission",
      "Properties": {
        "FunctionName": "arn:aws:lambda:<region>:<awsid>:function:<lambd name>",
        "Action": "lambda:InvokeFunction",
        "Principal": "events.amazonaws.com",
        "SourceArn": {
          "Fn::GetAtt": [
            "TagWatcherRule",
            "Arn"
          ]
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题