naoufal bardouni
naoufal bardouni

Reputation: 252

AWS: Help setting up CodeDeploy in a Codepipeline

It looks like it's impossible to get Codedeploy to work in a CodePipeline project with a CodeBuild.

First I set up a Pipeline with 3 stages: Source, Build and Deploy, the first 2 stages work perfectly but the 3th (CodeDeploy) throws this error: enter image description here

CodeBuild pushes the output artifacts to s3 in a .zip file, which is not supported by CodeDeploy.

For this, I tried to set up a Lambda function between CodeBuild and CodeDeploy like this: (Source -> CodeBuild -> Invoke Lambda -> CodeDeploy), The Lambda function uploads the appspec.yml file to s3 and calls putJobSuccessResult, But I still get the same error.

Upvotes: 0

Views: 666

Answers (1)

shariqmaws
shariqmaws

Reputation: 8890

BundleType must be either YAML or JSON

There is a known limitation where the deployment of a Lambda using CodePipeline, with CodeDeploy as the Deployment Provider is not supported as of yet.

This is because CodePipeline will always zip the bundle/artifact, whereas CodeDeploy expects a YAML/JSON file as the source (appspec.yaml file) for Lambda Function deployment.

In order to work around this limitation, you have two options:

  1. Run AWS CLI commands inside your CodeBuild Stage to update/deploy your lambda function

OR

  1. Use CodeBuild to package your lambda function Code and push the artifact to a CloudFormation stage, which will update or create your Lambda Function Resource. You should find the reference documentation at [1] useful for getting the required information about packaging your SAM application.

Ref:

[1] SAM Packaging - https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-deploying.html#serverless-sam-cli-using-package-and-deploy

Upvotes: 0

Related Questions