Home > Back-end >  Failed Bitbucket NodeJS repo Pipeline with AWS Lambda function with "Error parsing parameter &#
Failed Bitbucket NodeJS repo Pipeline with AWS Lambda function with "Error parsing parameter &#

Time:05-31

Our team is having a problem trying to set up a pipeline for update an AWS Lambda function.

Once the deploy is triggered, it fails with the following error:

Status: Downloaded newer image for bitbucketpipelines/aws-lambda-deploy:0.2.3
INFO: Updating Lambda function.
aws lambda update-function-code --function-name apikey-token-authorizer2 --publish --zip-file fileb://apiGatewayAuthorizer.zip
Error parsing parameter '--zip-file': Unable to load paramfile fileb://apiGatewayAuthorizer.zip: [Errno 2] No such file or directory: 'apiGatewayAuthorizer.zip'
*Failed to update Lambda function code.

Looks like the script couldn't find the artifact, but we don't know why.

Here is the bitbucket-pipelines.yml file content:

    image: node:16
# Workflow Configuration
pipelines:
default:
 - parallel:
 - step:
name: Build and Test
caches:
 - node
script:
 - echo Installing source YARN dependencies.
 - yarn install

branches:
testing:
 - parallel:
 - step:
name: Build 
script:
 - apt update && apt install zip
# Exclude files to be ignored
 - echo Zipping package.
 - zip -r apiGatewayAuthorizer.zip . -x *.git* bitbucket-pipelines.yml

artifacts:
 - apiGatewayAuthorizer.zip
- step:
name: Deploy to testing - Update Lambda code
deployment: Test
trigger: manual
script:
 - pipe: atlassian/aws-lambda-deploy:0.2.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: $LAMBDA_FUNCTION_NAME
COMMAND: 'update'
ZIP_FILE: 'apiGatewayAuthorizer.zip'

Does anyone knows what am I missing here?

CodePudding user response:

Thanks to Marc C. from Atlassian, here is the solution.

Based on your YAML configuration, I can see that you're using Parallel steps.

According to the documentation:

Parallel steps can only use artifacts produced by previous steps, not by steps in the same parallel set.

Hence, this is why the artifacts is not generated in the "Build" step because those 2 steps are within a parallel set.

For that, you can just remove the parallel configuration and use multi-steps instead. This way, the first step can generate the artifact and pass it on to the second step. Hope it helps and let me know how it goes.

Regards, Mark C

So we've tried the solution and it worked!. Here is the new pipeline:

    pipelines:
  branches:
    testing:
        - step:
            name: Build and Test
            caches:
              - node
            script:
              - echo Installing source YARN dependencies.
              - yarn install
              - apt update && apt install zip
              # Exclude files to be ignored
              - echo Zipping package.
              - zip -r my-deploy.zip . -x *.git* bitbucket-pipelines.yml
            artifacts:
              - my-deploy.zip
        - step:
            name: Deploy to testing - Update Lambda code
            deployment: Test
            trigger: manual
            script:
              - pipe: atlassian/aws-lambda-deploy:0.2.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: $LAMBDA_FUNCTION_NAME
                  COMMAND: 'update'
                  ZIP_FILE: 'my-deploy.zip'
                            
         
        
  • Related