简体   繁体   English

如何在CloudFormation模板中描述AWS Lambda函数测试事件?

[英]How to describe AWS Lambda function test events in CloudFormation template?

I describe existing AWS Lambda function in CloudFormation template and I face with the next issue. 我在CloudFormation模板中描述了现有的AWS Lambda函数,我将面对下一期。 In our Lambda we configured few test events which helps us to verify some usecases (I mean functionality from the screenshot below). 在我们的Lambda中,我们配置了一些测试事件,这有助于我们验证一些用例(我的意思是下面的截图中的功能)。

在此输入图像描述

But I don't see any abilities to add these test events to the CloudFormation template. 但我没有看到任何将这些测试事件添加到CloudFormation模板的能力。 AWS documentation don't help me with that. AWS文档对此没有帮助。 Is that possible at all or are there any workarounds how to export and import Lambda function test events? 这是可能的,还是有任何变通方法如何导出和导入Lambda函数测试事件?

Lambda test functionality is available only in the UI console, You can use Cloudformation Custom Resource to invoke a function from a cloudformation template. Lambda测试功能仅在UI控制台中可用,您可以使用Cloudformation Custom Resource从云信息模板调用功能。 Resource properties allow AWS CloudFormation to create a custom payload to send to the Lambda function. 资源属性允许AWS CloudFormation创建自定义有效负载以发送到Lambda函数。

Sample code: 示例代码:

Resources:
  EnableLogs:
    Type: Custom::EnableLogs
    Version: '1.0'
    Properties:
      ServiceToken: arn:aws:lambda:us-east-1:acc:function:rds-EnableRDSLogs-1O6XLL6LWNR5Z
      DBInstanceIdentifier: mydb

the event parameter provides the resource properties. event参数提供资源属性。 ex: 例如:

event['ResourceProperties']['DBInstanceIdentifier']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 CloudFormation 模板更新 AWS Lambda function - How do I update AWS Lambda function using CloudFormation template 如何为使用 CloudFormation 模板创建的 AWS Lambda function 添加触发器? - How to add triggers for a AWS Lambda function created using a CloudFormation template? 如何将 AWS Lambda 转换回 CloudFormation 模板 - How to convert AWS Lambda back into CloudFormation template 如何在 AWS CloudFormation 中描述实例 - How to describe an instance in AWS CloudFormation AWS CloudFormation中的Lambda函数 - Lambda Function in AWS CloudFormation 我可以使用 CloudFormation 模板更新 AWS Lambda function 吗? - Can I update AWS Lambda function using CloudFormation template? 如何使用cloudformation模板传递aws-lambda函数名称以生成cloudwatch警报 - How to pass aws-lambda function name to generate a cloudwatch alarm using cloudformation template 如何在 AWS CloudFormation 模板中使用参考号 function? - How is the !Ref function used in an AWS CloudFormation template? 需要有关 CloudFormation 模板和 AWS lambda 的帮助,以便通过 lambda 将事件从 SQS 拉到 S3 - Need help on CloudFormation template and AWS lambda for pulling events from SQS to S3 via lambda 如何在Cloudformation模板中为AWS Lambda定义MetricFilter? - How to define MetricFilter for AWS Lambda inside Cloudformation template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM