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

不羁的心 提交于 2019-12-23 07:15:30

问题


I describe existing AWS Lambda function in CloudFormation template and I face with the next issue. In our Lambda we configured few test events which helps us to verify some usecases (I mean functionality from the screenshot below).

But I don't see any abilities to add these test events to the CloudFormation template. AWS documentation don't help me with that. Is that possible at all or are there any workarounds how to export and import Lambda function test events?


回答1:


Lambda test functionality is available only in the UI console, You can use Cloudformation Custom Resource to invoke a function from a cloudformation template. Resource properties allow AWS CloudFormation to create a custom payload to send to the Lambda function.

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. ex:

event['ResourceProperties']['DBInstanceIdentifier']


来源:https://stackoverflow.com/questions/51783194/how-to-describe-aws-lambda-function-test-events-in-cloudformation-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!