amazon-web-services - AWS Lambda destination Lambda not triggering
问题描述
Background:
I'm developing a custom AWS github-webhook via Terraform. I'm using AWS API Gateway to trigger an AWS Lambda function that validates the GitHub webhook's sha256 signature from the request header. If the lambda function successfully validates the request, I want a child lambda function to be invoked via the async invocation destination feature provided by Lambda.
Problem:
Even though I've configured the async invocation with the target child Lambda function, the child function is not triggered when the parent Lambda function is successful. This is reflected in the fact that the child Lambda function's associated CloudWatch log group is empty.
Relevant Code:
Here's the Terraform configuration for the Lambda function destination:
resource "aws_lambda_function_event_invoke_config" "lambda" {
function_name = module.github_webhook.function_name
destination_config {
on_success {
destination = module.lambda.function_arn
}
}
}
If more code from the module is needed, feel free to ask in the comments. The entire source code for this module is here: https://github.com/marshall7m/terraform-aws-codebuild/tree/master/modules/dynamic-github-source
Attempts:
- Made sure both parent/child Lambda functions have permission to create logs within their respective Cloudwatch log group (attached
arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
policy to both) - Made sure the parent Lambda function has the correct permission to invoke the child function:
"lambda:InvokeFunction", "lambda:InvokeAsync"
- Setup async invocation for child lambda function for both success and failure parent Lambda runs (child function still not triggered)
- Add API integration request parameter `{'X-Amz-Invocation-Type': 'Event'} as mentioned in: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html
- For every attempt to fix this, I made sure to redeliver the request from the source (github webhook page) and not via the AWS Lambda console.
解决方案
From your description it seems to me that you are invoking parent function synchronously. Lambda destinations are only for asynchronous invocations:
You can also configure Lambda to send an invocation record to another service. Lambda supports the following destinations for asynchronous invocation
So you have to execute your parent function asynchronously for your child function to be invoked.
推荐阅读
- android - 长按编辑文本时限制/删除自动填充选项
- python - 如何将列(average_user_rating)添加到数据框中,为我提供该行中 userId 的平均评分?
- sql - sql server 12中非常奇怪的索引性能
- python - 禁止命令 discord.py 的问题(重写分支)
- c++ - 编译创建 Eigen::ThreadPoolDevice 对象的代码时出错
- javascript - 如何在节点 js 中通过相同的路由在两个模式中添加相同的数据?
- html - 兄弟姐妹的孩子在悬停时影响兄弟姐妹
- python - Python - 通过唯一ID拆分的数字列的差异扩展数据框
- python - 在 Python 中使用 Twitch IRC 时“由对等方重置连接”
- jquery - 根据在联系表 7 的表单字段中的下拉列表中选择的选项将用户重定向到不同的感谢页面(3 个选项到 3 个感谢页面)