CodePipeline LambdaInvokeAction never stops even though the underline lambda ends immediately
See original GitHub issueI use CDK CLI version 1.0.0 with aws-cdk version 1.0.0 on Windows 10 with TypeScript.
- What is the current behavior? Creating a codepipeline with 2 stages
- source from codecommit
- lambda
CodePipeline Lambda action stage never stops. If I try running the underline lambda function directly, it stops immediately.
- What is the expected behavior (or behavior of feature suggested)? CodePipeline Lambda action stage should stop.
const pipelineName = `${props.service.serviceName}_${props.sourceTrigger}`;
this.pipeline = new Pipeline(this, pipelineName, {
pipelineName,
restartExecutionOnUpdate : true
});
// Source
const sourceOutput = new codepipeline.Artifact();
const repo = codecommit.Repository.fromRepositoryName(this, "Repo", props.service.repo.name);
const sourceAction = new codepipeline_actions.CodeCommitSourceAction({
actionName: 'CodeCommit',
repository: repo,
branch: props.service.repo.branch,
output: sourceOutput
});
this.pipeline.addStage({
stageName: 'Source',
actions: [sourceAction]
});
const fn = new lambda.Function(this, 'LambdaFun', {
code: new lambda.InlineCode(`
exports.handler = function () {
console.log("Hello, world!");
};
`),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_8_10,
});
const lambdaAction = new codepipeline_actions.LambdaInvokeAction({
lambda: fn,
actionName: 'IncrementBuildNumber',
userParameters: {"ssmParamProjectBuildPath": '/CodeBuild/build-versions/nextGen-api-authProvider/test-build'}
});
this.pipeline.addStage({
stageName: 'IncrementBuildNumber',
actions: [lambdaAction]
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Invoke an AWS Lambda function in a pipeline in CodePipeline
To create resources on demand in one stage of a pipeline using AWS CloudFormation and delete them in another stage. To deploy application...
Read more >Lambda function never succeeds in codepipeline
When I run my Lambda function in Codepipeline it ends properly and does what I want as I can see in logs, but...
Read more >Lambda Process Exited Before Completing Request - Dashbird
The "Lambda Process Exited Before Completing Request" error is mostly related to legacy behavior. Let's debug it.
Read more >Running AWS Lambda Functions in AWS CodePipeline using ...
Now, you can run event-driven functions any time you want from your pipelines. With this addition, CodePipeline added a new Invoke action ...
Read more >Tutorial: Using variables with Lambda invoke actions
For information about variables for actions in CodePipeline, see Variables. At the end of this tutorial, you will have: A Lambda invoke action...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @byabrik ,
I think there’s been a little misunderstanding.
The example I’ve shown is just a trivial Lambda that doesn’t actually do anything, just immediately succeeds the Action. Of course, in reality, the purpose of putting a Lambda in your pipeline is for it to do something. Now, depending whether that “something” was a success or not, you would call either the
putJobSuccessResult
or theputJobFailureResult
API in your Lambda, which either succeeds or fails the execution of the Action, respectively. You always have to call one of those 2 APIs – otherwise, the Action will never stop executing, and finally time out after an hour.This “something” is not a thing the CDK can do for you - it’s specific to your use case, whatever it is that you need a Lambda for in the first place. The CDK is for infrastructure, your custom business logic is still up to you to write 😃.
As for customizing the behavior of your Lambda - you can use input & output artifacts for that. If you need further customizations, there is a field called userParameters that you can pass when creating the Action, and then read as a field of
event
in your Lambda. This way you can re-use the same Lambda in multiple parts of the Pipeline, and customize it at every spot it’s used.Hope this helps.
Thanks, Adam
@skinny85, it works with the addition of the PutJobSuccessResult, but it makes the lambda not reusable. What If I have a lambda that could be run in the end of the pipeline or in the middle? In that case we would have to pass some kind of parameter into the lambda to understand if I need to call PutJobSuccessResult or not. Would be nice if cdk would just do something automatically. For example grab the result of the last job in the pipeline and submit PutJobSuccessResult/PutJobFailureResult on behalf of the user.