It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

When aws lambda pipe is used twice in a pipeline second run produces error Edited

I have a pipeline with 3 steps 2 of them using the pipe aws-lambda-deploy with update command.

The first instance of pipe works as expected.

The second instance of the pipe works (updates correctly in AWS) but it fails with error:

INFO: Update command succeeded.INFO: Writing results to file /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/aws-lambda-deploy-env./usr/bin/update-lambda.sh: line 22: /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/aws-lambda-deploy-env: Permission denied

 

I assume this is because of the artefact being created in prev step and something to do with permissions in artefacts.

 

Here is my bitbucket-pipelines.yml

 

 

image: node:8

pipelines:
default:
- step:
name: Run Tests
caches:
- node
script:
- cd ./lambda
- npm install
- npm test
- step:
name: Build lambda artefacts
caches:
- node
script:
- apt update
- apt install zip -y
- echo "Building lambda"
- ./ops/build.sh lambda
artifacts:
- "lambda.zip"
- step:
name: Deploy Lambda stage
trigger: automatic
deployment: staging
script:
- pipe: atlassian/aws-lambda-deploy:0.3.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_STAGE
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY_STAGE
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
FUNCTION_NAME: 'stage-lambda'
COMMAND: 'update'
ZIP_FILE: 'lambda.zip'
- step:
name: Deploy Lambda Production
trigger: manual
deployment: production
script:
- cat $BITBUCKET_PIPE_SHARED_STORAGE_DIR/aws-lambda-deploy-env
- rm $BITBUCKET_PIPE_SHARED_STORAGE_DIR/aws-lambda-deploy-env
- pipe: atlassian/aws-lambda-deploy:0.3.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_PRODUCTION
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY_PRODUCTION
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
FUNCTION_NAME: 'production-lambda'
COMMAND: 'update'
ZIP_FILE: 'lambda.zip'

 

 

 

2 answers

1 accepted

1 vote
Answer accepted

Hi Yavor. There is a currently unknown issue with the state sharing between pipes. You should roll back to using the 0.2.3 version of the aws-lambda-deploy pipe for the time being.

I have a workaround (delete state file between steps), just wanted to report it.

Like Fabian Zorro Daza likes this

I am also facing the same issue with atlassian/aws-sam-deploy:0.2.3 

@Yavor Shahpasov  could you please share the details how we "delete state file between steps", if it is helpful

See full pipeline, some parts removed for readability. 

Note the rm command in the second step. The file aws-lambda-deploy-env was the one causing a problem in my case.

image: node:8

pipelines:
default:
- step:
name: Run Tests
script:
...
- step:
name: Build lambda artefacts
caches:
- node
script:
- apt update
- apt install zip -y
artifacts:
- "file.zip"
- step:
name: Deploy Lambda Stage
trigger: automatic
deployment: staging
script:
- pipe: atlassian/aws-lambda-deploy:0.3.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_STAGE
...
# The artefact causes the second run to fail.
- rm /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/aws-lambda-deploy-env
- step:
name: Deploy Lambda Production
trigger: manual
deployment: production
script:
- pipe: atlassian/aws-lambda-deploy:0.3.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_PRODUCTION
...

It worked..!! Thanks a lot

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,052 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you