是否可以在 AWS CDK 中定义多个 lambda 目的地?

Is it possible to define multiple lambda destinations in AWS CDK?

我在 AWS CDK 中有以下 lambda 函数:

checker_destination = lambda_destinations.LambdaDestination(checker_function)
sns_destination = lambda_destinations.SnsDestination(monitoring_topic)
    
    rls_function = _lambda.Function(
        #Other parameters left out for this question since they are not relevant
        on_success=checker_destination, 
        on_failure=checker_destination
    )

不过,我还想将 sns 目标添加到 on_failure 参数中。这在 AWS Cdk 中可能吗? on_failure 需要一个目的地,而不是目的地数组,因此 [checker_destination,sns_destination] 不起作用

不,但这不是 CDK 的限制,而是 Lambda 服务本身的限制,您只能有一个成功和失败目标,不能有多个。请参阅 API 中的 DestinationConfig

如果你想要多个目标,你需要自己创建扇出,例如将 SNS 指定为目标,然后将多个内容订阅到该 SNS 主题。