1

I'm attempting to setup CodePipeline to manage the deployment of a very simple Lambda function.

I'm completely stuck on a problem with the deployment step, and cannot figure out what could be wrong.

When the pipeline attempts to run the CodeDeploy action, it fails with the error...

BundleType must be either YAML or JSON

This is my appspec...

version: 0.0
Resources:
  - my-function:
      Type: AWS::Lambda::Function
      Properties:
        Name: "my-function"

My pipeline doesn't have a build step, as it's just a simple js file, with no dependencies, so no build is required.

I've tried adding an action to deploy to S3, and I can confirm that the zip file that's being sent to s3 contains the appspec.yml and index.js and that these are both in the root.

Most of the examples I've seen use a buildspec, but I'm not sure why I would need this, or what it would even do if I had one.

1 Answer 1

7

There is nothing wrong with your setup, it is a shortcoming of the services that you cannot use CodeDeploy in a CodePipeline action to Deploy a Lambda function.

The reason is because CodeDeploy expects a JSON or YAML appspec file for the Lambda deployment, but currently CodePipeline supports ZIP as a bundle type so the error is thrown.

To workaround, customers deploy Lambda in a CodePipeline is via CloudFormation deploy action (SAM to be exact). Please see this tutorial on this recommended approach:

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. This helps a lot. I actually ended up hacking together a workaround that involved the pipeline deploying first to S3, and then invoking another lambda which called the sdk "updateFunctionCode". It works, but doesn't seem like an ideal way to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.