Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 sam deploy Edited

Hi dear community,

We're currently facing a problem with deploying lambda function's artefacts together with 3rd party libraries.

Could you please clarify, how to resolve and deploy properly these dependencies using aws-sam-deploy pipe?

 

* we use the last version of pipe.

variables in BBPL file:

variables:
AWS_ACCESS_KEY_ID$AWS_ACCESS_KEY_ID_STAGE
 AWS_SECRET_ACCESS_KEY$AWS_SECRET_ACCESS_KEY_STAGE
 AWS_DEFAULT_REGION'eu-central-1'    
 
S3_BUCKET'templates-stage' 
  
STACK_NAME'stackname'                
SAM_TEMPLATE'template.yaml'            
  
CAPABILITIES: ['CAPABILITY_IAM''CAPABILITY_AUTO_EXPAND']
D
EBUG'true'

To reproduce: 

add requirements.txt file( with e.g. psycopg2-binary) to your lambda source code. Deploy. In S3 bucket you'll see that the file uploaded to S3 bucket is too small and Lambda is not working.

 

Best Regards,

Alexey

4 answers

Had exact same problem. The issue is that Bitbucket's pipeline doesn't actually use AWS' SAM command. It is doing something weird. If you try to deploy yourself using sam deploy, everything will be fine. Here's pipeline I made myself that works perfectly.

1. Run aws sam locally first to create samconfig.toml. Merge it to the branch.

2. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables in the repository's settings.

- step:
name: deploy to AWS
image: python:3.7
script:
- apt-get update
- curl -LkSs https://github.com/awslabs/aws-sam-cli/archive/v0.40.0.tar.gz -o aws-sam.tar.gz
- tar -xf aws-sam.tar.gz
- "cd ./aws-sam-*"
- make - cd ../
- samdev --version
- export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- samdev build
- yes | samdev deploy

 H

Any updates on this?

I've faced with exact same problem. I need to deploy AWS stack, which contains some AWS services and Lambda. Lambda using 3rd party libraries. After deploy, Lambda code raises an error, because 3rd party libraries can't be found

I think, this might be  somehow related to https://github.com/awslabs/aws-sam-cli/issues/978#issue-406800072. `aws-sam-deploy` pipe uses `sam package ---template-file",  and with it somehow packages are properly installed and uploaded. 

0 votes

Hi everyone, 

I struggled with the same issue for a while, and came up with the following:

- step:
name: Build & Deploy to Production
script:
- pip install aws-sam-cli # install sam cli first
- sam build # package the project properly
- cd .aws-sam/build # all packages (one folder per function) are located here
- pipe: atlassian/aws-sam-deploy:0.5.2
variables:
SOME_VARIABLE: 'some value...'

Long story short, you'll need the three extra commands (the ones with comments next to them) to create the packages before you call sam-deploy. 

I checked the current version of the lib (aws-sam-deploy:0.5.2) and I wasn't able to figure out how the commands "sam build" and "sam deploy" are triggered. For that reason I decided to run the build as an extra step and be sure that everything is packaged the way I want. Then it seems that the pipe can do the rest. I'd really appreciate some clarification here from the team that created this one.

 I also wanted to raise one question about the solution provided by @Ignas Pbecause I feel there is a week point there. In my opinion the requirement to create the samconfig file on the localhost limits this solution from being dynamic. As an example, when one adds a new lambda function, she has to remember to re-generate this config before she runs the pipeline. Please let me know your thoughts on that there is something I have missed.

Cheers,
Chris

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,237 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