I'm unable to use AWS CodeDeploy for Lambda via Bitbucket Pipelines. It's saying that the bundle needs to be YAML or JSON, but the documentation and examples indicate that I need to create a zip file. Can anyone give me some guidance here? Details follow.
Version of pipe: atlassian/aws-code-deploy:0.5.2
Steps to reproduce: Pushing changes to master branch, triggering a pipeline job.
I created my pipeline file using this documentation.
bitbucket-pipelines.yml:
pipelines:
default:
- step:
name: Build and package
script:
- apt-get update && apt-get install -y zip
- zip myapp.zip lambda_function.py appspec.yaml
artifacts:
- myapp.zip
- step:
name: Upload lambda zip
script:
- pipe: atlassian/aws-code-deploy:0.5.2
variables:
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
COMMAND: 'upload'
APPLICATION_NAME: $APPLICATION_NAME
ZIP_FILE: 'myapp.zip'
Relevant Build Log:
aws s3 cp myapp.zip s3://<bucket>/<key>
INFO: Registering a revision for the artifact.
aws deploy register-application-revision --application-name <app-name> --revision revisionType=S3,s3Location={bucket=<bucket>,key=<key>,bundleType=zip}
An error occurred (InvalidRevisionException) when calling the RegisterApplicationRevision operation: BundleType must be either YAML or JSON
Hi @Jack Brooks ,
Thank you for your question!
We are working on aws-code-deploy pipe adding support AWS ECS and Lambda deploy, not only EC2.
Could you please share more details with us, why did you decide to use aws-code-deploy to deploy lambda instead of aws-lambda-deploy or aws-sam-deploy?
One of the solutions, in your case, might be:
image: atlassian/default-image:2
pipelines:
default:
- step:
name: Build and package
script:
- apt-get update && apt-get install -y zip
- zip myapp.zip lambda_function.py appspec.yaml
artifacts:
- myapp.zip
- step:
name: Deploy lambda
script:
# Update lambda code and publish a new version
- pipe: atlassian/aws-lambda-deploy:0.5.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
FUNCTION_NAME: $FUNCTION_NAME
COMMAND: 'update'
ZIP_FILE: 'myapp.zip'
# Read results from the update pipe into environment variables
-BITBUCKET_PIPE_SHARED_STORAGE_DIR="/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes"
- VERSION=$(jq --raw-output '.Version' $BITBUCKET_PIPE_SHARED_STORAGE_DIR/aws-lambda-deploy-env)
# Point an alias to the new lambda version
- pipe: atlassian/aws-lambda-deploy:0.5.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
FUNCTION_NAME: $FUNCTION_NAME
COMMAND: 'alias'
ALIAS: 'production'
VERSION: '${VERSION}'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.