【问题标题】:CDK step function to get the status from lambda从 lambda 获取状态的 CDK 阶跃函数
【发布时间】:2021-04-17 12:26:36
【问题描述】:

我正在关注example suit,以便能够创建步进函数并执行 lambda。 不过,我对捕捉 lambda 响应的状态非常感兴趣。

根据文档, // Lambda's result in a field called "status" in the response result in a field called status 是什么意思?谁能阐明如何将结果作为状态放入字段中?我是在 python 中做的。

【问题讨论】:

    标签: python aws-lambda aws-cdk aws-step-functions


    【解决方案1】:

    有两种方法可以从阶跃函数中捕获 lambda 函数的响应。

    1. 使用add_retryadd_catch 处理来自lambda 函数的任何异常 例如。
                .start(record_ip_task
                       .add_retry(errors=["States.TaskFailed"],
                                  interval=core.Duration.seconds(2),
                                  max_attempts=2)
                       .add_catch(errors=["States.ALL"], handler=notify_failure_job)) \
    
    1. 来自 lambda 函数的响应值,例如 return '{"Result": True},然后步进函数作业将检查该值以用于下一个任务,例如。
                                .next(
                                    is_block_succeed
                                        .when(step_fn.Condition.boolean_equals('$.Result', False), notify_failure_job)
                                        .otherwise(send_slack_task)
                                )
    

    参考:https://dev.to/vumdao/aws-guardduty-combine-with-security-hub-and-slack-17eh

    【讨论】:

    • 链接可以使用,但是一些重要的内容链接无法使用,例如Step function and state machine for catching IPv4,您可以分享我更新的内容或 GitHub 以供参考。
    • 谢谢,@vumado 赞赏。我已经创建了另一个请求,您可以看看stackoverflow.com/questions/67166351/…
    猜你喜欢
    • 2020-12-16
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 2020-03-14
    • 2021-04-12
    • 1970-01-01
    • 2019-02-21
    • 2021-11-05
    相关资源
    最近更新 更多