I'm trying to create a Lambda function that works with CodePipeline. The issue is that it can't send the job success info to CodePipeline. I'm using the javascript aws-sdk and the function putJobSuccessResult from the AWS.CodePipeline objects don't execute fine in production.
const AWS = require('aws-sdk');
const codepipeline = new AWS.CodePipeline();
exports.config = (event, context) => {
// Retrieve the Job ID from the Lambda action
const jobId = event['CodePipeline.job'].id;
return codepipeline.putJobSuccessResult({ jobId }).promise();
};
This code works fine locally when I put the jobId of my pipeline but when I upload the code on the AWS Console and run the pipeline, it doesn't work anymore.
Here is the IAM Configuration for the Lambda specific to CodePipeline part:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"codepipeline:PutJobSuccessResult",
"codepipeline:PutJobFailureResult"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Do you have any ideas about why it doesn't work on the cloud ?