0

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.

naoufal bardouni
  • 241
  • 3
  • 11

1 Answers1

0

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

shariqmaws
  • 8,152
  • 1
  • 16
  • 35
  • I used an AWS Lambda as a stage between CodeBuild and CodeDeploy, the lambda doesn't Zip the output artifacts and only upload one file to s3 which is a .yaml, and I still get the same error. – naoufal bardouni Jan 16 '20 at 17:07
  • I noticed your appspec file name is 'appspec.yml' whereas CodeDeploy Lambda deployment requires 'appspec.yaml' - https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html – shariqmaws Jan 17 '20 at 15:18
  • I tried all the these names "appspec.yml", "appSpec.yml", "appspec.yaml" and "appSpec.yaml" and non of them worked, I looks like its not supported to use codebuild and codedeploy together in a pipeline. – naoufal bardouni Apr 01 '20 at 12:07
  • 1
    Sorry, It's nothing to do with the filename, it is the zip issue as mentioned in my original answer. "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." – shariqmaws Apr 05 '20 at 07:26
  • Well, 6 months later and still no solution for this... The first option in this answer worth a shot. – Tarek Nov 09 '20 at 07:37