问题
When I run my Lambda function in Codepipeline it ends properly and does what I want as I can see in logs, but it never succeeds in pipeline. It just shows In Progress when actually my Lambda function does its job in logs.
What am I missing? Maybe I need to send 'putJobSuccessResult' as shown here to CodePipeline? But if so then why if it's not a custom action?
And what are custom actions at all? What is the difference between them and non-custom actions?
回答1:
Maybe I need to send 'putJobSuccessResult' as shown here to CodePipeline?
Yes, you need to call putJobSuccessResult from your Lambda function.
But if so then why if it's not a custom action?
This tells CodePipeline that your Lambda function is finished, and what to do next.
CodePipeline has a feature where if you pass a 'continuation token' then CodePipeline will re-invoke your function and pass the state in the continuation token to the next invocation. This allows you to have actions running longer than the Lambda invocation timeout. You can pass this info when you call putJobSuccessResult.
Also, it separates "failing an action" from "failing the function". This allows you to fail the action without failing the lambda function. This is desirable because Lambda has a retry behavior if the function fails.
And what are custom actions at all?
With a custom action you need your own code to call PollForJobs, which typically runs on eg. a long running EC2 instance. The Lambda invoke action will call a Lambda function without you having to run your own instance / host.
来源:https://stackoverflow.com/questions/52059912/lambda-function-never-succeeds-in-codepipeline