Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

aws-lambda-deploy pipe how to fix aws-lambda-deploy-env: Permission denied

As part of running the pipe below

- pipe: atlassian/aws-lambda-deploy:0.5.7
variables:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: 'eu-west-2'
FUNCTION_NAME: 'MyFunction'
COMMAND: 'update'
ZIP_FILE: 'code.zip'

The script update-lambda.sh writes to /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/aws-lambda-deploy-env. That file is then read by pipe.sh in a subsequent pipe when you run with the alias command. e.g.  

COMMAND: 'alias'

However if I have another pipe in my bitbucket-pipelines.yml file before the aws-lambda-deploy pipe. e.g. 

sonarsource/sonarcloud-scan:1.2.1

then update-lamda.sh cannot write the aws-lambda-deploy-env file as it gets a permission denied error.

Shouldn't the aws-lambda-deploy-env file be created in /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/atlassian/aws-lambda-deploy   ?

And why does the creation of the /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/ by another pipe stop it being available for the subsequent pipe? 

2 answers

1 accepted

1 vote
Answer accepted

The solution was to delete the shared directory before running the aws-lambda-deploy pipe. 

... previous steps call the sonarsource/sonarcloud-scan pipe ...
-
step:
name: 'Deploy Lambda to AWS'
script:
# Writing the $BITBUCKET_PIPE_SHARED_STORAGE_DIR/aws-lambda-deploy-env file causes a permissions denied failure, so we first delete the directory
- rm -rf /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes
- pipe: atlassian/aws-lambda-deploy:0.5.7
variables:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: 'eu-west-2'
FUNCTION_NAME: 'MyFunction'
COMMAND: 'update'
ZIP_FILE: 'code.zip'
 

Still don't know why running the sonar pipe first prevents the aws pipe from writing to the shared storage location

Suggest an answer

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

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

184 views 2 4
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