简体   繁体   English

AWS Lambda 未向 AWS SQS DLQ 发送错误消息

[英]AWS Lambda is not sending error messages to AWS SQS DLQ

I'm trying to create via terraform, a lambda that triggered by Kinesis and her destination on failures will be AWS SQS.我正在尝试通过 terraform 创建一个由 Kinesis 触发的 lambda,她在失败时的目标将是 AWS SQS。

I created and lambda and configured the source and destination我创建了 lambda 并配置了源和目标

运动配置

When I'm sending a message to Kinesis queue, the lambda is triggered but not sending messages to the DLQ.当我向 Kinesis 队列发送消息时,会触发 lambda 但不会向 DLQ 发送消息。

What am I missing?我错过了什么?

my labmda source mapping:我的 labmda 源映射:

resource "aws_lambda_event_source_mapping" "csp_management_service_integration_stream_mapping" {
  event_source_arn               = local.kinesis_csp_management_service_integration_stream_arn
  function_name                  = module.csp_management_service_integration_lambda.lambda_arn
  batch_size                     = var.shared_kinesis_configuration.batch_size
  bisect_batch_on_function_error = var.shared_kinesis_configuration.bisect_batch_on_function_error
  starting_position              = var.shared_kinesis_configuration.starting_position
  maximum_retry_attempts         = var.shared_kinesis_configuration.maximum_retry_attempts
  maximum_record_age_in_seconds  = var.shared_kinesis_configuration.maximum_record_age_in_seconds
  function_response_types        = var.shared_kinesis_configuration.function_response_types
  destination_config {
    on_failure {
      destination_arn = local.shared_default_sqs_error_handling_dlq_arn
    }
  }
}
resource "aws_iam_policy" "shared_deadletter_sqs_queue_policy" {
  name = "shared-deadletter-sqs-queue-policy"
  path = "/"
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action   = [
          "sqs:SendMessage",
        ]
        Effect   = "Allow"
        Resource = [
          local.shared_default_sqs_error_handling_dlq_arn
        ]
      },
    ]
  })
}

I think you are facing some permission issue, try attaching a role to your lambda function with access to AWS SQS DLQ.我认为您面临一些权限问题,请尝试将角色附加到您的 lambda function 以访问 AWS SQS DLQ。

You should take a look on the following metric to see if you have permission error您应该查看以下指标,看看您是否有权限错误

Lambda 指标

  1. Is your DLQ encrypted by KMS?您的 DLQ 是否通过 KMS 加密? You will need top provide permissions to the KMS too in addition to SQS permissions除了 SQS 权限之外,您还需要提供对 KMS 的最高权限

  2. How is Lambda reporting failure? Lambda是怎么报错的?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM