Amazon web services 将参数传递给AWS Cloudwatch事件目标lambda函数

Amazon web services 将参数传递给AWS Cloudwatch事件目标lambda函数,amazon-web-services,aws-lambda,amazon-cloudformation,aws-event-bridge,Amazon Web Services,Aws Lambda,Amazon Cloudformation,Aws Event Bridge,我想将参数传递给AWS Cloudwatch事件调用的lambda函数。参数名称为alarmActions,事件规则的我的CFT模板如下: "LambdaInvokeScheduler": { "Type": "AWS::Events::Rule", "Properties": { "Description": "

我想将参数传递给AWS Cloudwatch事件调用的lambda函数。参数名称为
alarmActions
,事件规则的我的CFT模板如下:

"LambdaInvokeScheduler": {
            "Type": "AWS::Events::Rule",
            "Properties": {
              "Description": "Scheduled Rule for invoking lambda function",
              "EventPattern": {
                "source": [
                  "aws.ecs"
                ],
                "detail-type": [
                  "ECS Container Instance State Change"
                ],
                "detail": {
                  "clusterArn": [
                    { "Fn::GetAtt": ["WindowsCluster", "Arn"] }
                  ]
                }
              },
              "State": "ENABLED",
              "Targets": [{
                "Arn": { "Fn::GetAtt": ["AlarmCreationLambdaFunction", "Arn"] },
                "Id": "AlarmCreationLambdaFunction",
                "Input": { "Fn::Join" : ["", [ "{ \"alarmActions\": \"", { "Fn::Join" : [":", [ "arn:aws:sns", { "Ref" : "AWS::Region" }, { "Ref" : "AWS::AccountId" }, "CloudWatch"]] }, "\" }"]] }
              }]
            }
          }

我使用了
Input
参数来传递JSON文本。关于它的文档并不多。我只是想找到正确的方法。我找到了解决办法。我以错误的方式引用lambda中的参数

我的lambda函数是这样的:

def func(event, context, alarmActions)
{
   print(alarmActions)
}
当我进行以下更新时,它起到了作用:

def func(event, context)
{
   print(event['alarmActions'])
}

lambda的示例输入是什么?它将有助于解决您的问题。在云信息中传递输入是正确的方法。