-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for input and output artifacts in the Lambda invoke CodePipeline Action #1384
Comments
Quoting discussion from gitter channel:
@skinny85 here is an example lambda function: exports.handler = async (event) => {
console.log('EV:', JSON.stringify(event));
// .. handle codepipeline input artifacts ..
// .. s3 upload output artifacts ..
} which outputs the following {
"CodePipeline.job": {
"id": "ae5410b4-f587-4440-81fe-63754c01beb4",
"accountId": "123123213",
"data": {
"actionConfiguration": {
"configuration": {
"FunctionName": "InfrastructureStack-MyServiceDevEclECSECSClusterDe-JKL1ZHL8PE45"
}
},
"inputArtifacts": [
{
"location": {
"type": "S3",
"s3Location": {
"objectKey": "TEST_ecr-deploy-pipe/SourceArti/A0NL7zF",
"bucketName": "codepipeline-eu-central-1-123123213"
}
},
"revision": "sha256:ed82e395895e03986043c5c5dffc009f9bc5be00485318693bfd1941596f3b87",
"name": "SourceArtifact"
}
],
"outputArtifacts": [
{
"location": {
"type": "S3",
"s3Location": {
"objectKey": "TEST_ecr-deploy-pipe/imageJson/1TQ1xBg",
"bucketName": "codepipeline-eu-central-1-123123213"
}
},
"revision": null,
"name": "imageJson"
}
],
"artifactCredentials": {
"...": "..."
}
}
} The job of the lambda function is now to upload the exports.handler = async (event) => {
// input artifacts example:
const inputArtifactLocation = ev["CodePipeline.job"].data.inputArtifacts[0].location.s3Location
// output artifacts example:
const {bucketName, objectKey} = event["CodePipeline.job"].data.outputArtifacts[0].location.s3Location
// user parameter example:
const key = ev["CodePipeline.job"].data.actionConfiguration.configuration.UserParameters
// upload output artifact to artifact-bucket:
return s3.putObject({
Bucket: bucketName,
Key: objectKey,
Body: // TODO: ... zip file ...
}).promise().then(() => putJobSuccessResultAsync({
jobId: event["CodePipeline.job"].id
})).then(() => { To complete this, here is how it looks in the aws console: |
According to the reference documentation, a Lambda Action can have up to 5 inputs, and up to 5 outputs. We should allow modeling these in the Action.
Reported by @defel on our Gitter channel.
The text was updated successfully, but these errors were encountered: