11

CodeDeploy reports "BundleType must be either YAML or JSON"

appspec.yml is in the root dir of CodeCommit

buildspec.yml:

version: 0.2

phases:
  build:
    commands:
      - echo Build started on `date`
      - echo Compiling the Python code...
      - python HelloWorld_tst.py
  post_build:
    commands:
      - echo Build completed on `date`
artifacts:
  files:
    - HelloWorld.py
    - appspec.yml
  discard-paths: yes

appspec.yml

version: 0.0
Resources:
    - autovisionfunction:
        Type: AWS::Lambda::Function
        Properties:
            Name: "autovisionfunction"
            Alias: "staging"
            CurrentVersion: "1"
            TargetVersion: "2"
            

Seems while in CodePipeline can't find appspec.yml

I have downloaded artefact zip from S3 bucket, it has appspec.yml inside.

enter image description here

What do I miss?

Thank you

Olya

Olya Basalay
  • 111
  • 1
  • 4
  • 1
    Are you sure the file extension has to be `.yml`? For over 12 years the [officially recommended extension](https://web.archive.org/web/20060924190202/http://yaml.org/faq.html) for YAML files has been `.yaml` – Anthon Nov 04 '18 at 08:49
  • 1
    I tried all possible formats and extensions, issues still remains `appspec.json appspec.yaml appspec.yml buildspec.yml HelloWorld_tst.py HelloWorld.py` – Olya Basalay Nov 04 '18 at 18:42

1 Answers1

16

I've currently been struggling with the same issue.

After some digging, I've found that it looks to be a limitation of linking the two services (codebuild and codedeploy) via codepipelines

Currently codebuild only supports ZIP/TAR/TGZ as the bundletypes (outputs) which codedeploy doesnt support

similar thread with an AWS response https://forums.aws.amazon.com/thread.jspa?messageID=864336

A work around is to trigger the codedeploy via the codebuild::project buildspec. Example below

export REVISION="revisionType=S3,s3Location{bucket=$BUCKET_DEPLOYMENTS,key=$CODEBUILD_BUILD_ID/appspec.yml,bundleType=YAML}"

aws deploy create-deployment \
    --application-name=$APPLICATION_NAME \
    --deployment-group-name=$DEPLOYMENT_GROUP_NAME \ 
    --revision=$REVISION \
    --deployment-config-name='CodeDeployDefault.LambdaCanary10Percent30Minutes'

Hopefully this gives you some ideas on how to work out the limitation

Regards,

sam_gordon
  • 161
  • 2