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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,409,312
Community Members
 
Community Events
169
Community Groups

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it.

I'm building Node.js Lambda functions using node-lambda that allows for development and testing in a local environment. 

In a simple example by adding following bitbucket-pipelines.yml into the project repository my Lambda function gets deployed on every push. I am using environment variables feature to populate $AWS_ACCESS_KEY and $AWS_SECRET_KEY.

image: lambci/lambda:build-nodejs6.10
pipelines:
default:
- step:
script:
- npm install
- npm install node-lambda -g
- node-lambda deploy -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY
caches:
- node

With properly configured node-lambda you will get a green pipeline that indicated successful deployment on a first push:

Screen Shot 2017-12-28 at 13.42.46.png

With the recent addition of Bitbucket Deployments, you can take this solution further and keep track of multiple Lambda environments.

To add deployments tracking with manual production promotion modify YML as follows:

image: lambci/lambda:build-nodejs6.10
pipelines:
default:
- step:
deployment: staging
script:
- npm install
- npm install node-lambda -g
- node-lambda deploy -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY -e staging
caches:
- node
- step:
deployment: production
trigger: manual
script:
- npm install
- npm install node-lambda -g
- node-lambda deploy -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY -e production
caches:
- node

And if everything goes well you should be able to see similar screen to this:

Screen Shot 2017-12-28 at 13.59.15.png

2 comments

The problem with node-lambda is that is does not yet support Lambdas versioning and aliases, which we use to manage environments rather than separately named functions. In our test environment, test apps call functions with a test qualifier. Therefore we use grunt-aws-lambda as it does support this feature.

 

We also use the tags feature in pipelines, which allow us to trigger a deployment based on a certain tag.

image: node:6.10
pipelines:
tags:
test/*:
- step:
caches:
- node
deployment: test
script:
- npm install -g grunt grunt-cli
- npm install
- grunt deploy_test
release/*:
- step:
caches:
- node
deployment: production
script:
- npm install -g grunt grunt-cli
- npm install
- grunt deploy_prod

 

deploy_test and deploy_prod are grunt tasks configured in Gruntfile.js, which contain the deployment options including the aliases, etc.

I'm always getting a role missing error in this pipeline definition, what could be the problem?

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events