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

Deploy Lambda via Bitbucket Pipeline using AWS Lambda Deploy

I want to add environment variable with lambda while pushing from bitbucket. How we can achieve the same using


AWS Lambda Deploy Pipes


Please let me know, if there is a way to attach enviornment variable with lambda once they are pushed

1 answer

@Ashish Awasthifirstly, you need to create your lambda or update the lambda with environment variable. The only way I know - it can be done via sam template.


You can do this with sam deploy pipe. See example how to do this with sam deploy .

For this pipe you will provide sam template, where you mention variables section and put there variables you will need.

Here I provide with docs that you may need to do this in aws:

-  - first example is that how you pass lambda environment variables to the template.yaml .  You can go basically with this doc and use basic examples from sam-deploy pipe


- BUT If you do not want to expose your environment variables (e.g., they are sensitive) in Bitbucket Cloud - use AWS embedded parameters for that  ( ) like here:

Type: String
your other setting for your lambda function
Function: Runtime: nodejs12.x Timeout: 180 Handler: ... Environment: <---- your env variables Variables: TABLE_NAME: !Ref TableName  <----- here you refer to parameters

and our STACK_PARAMETERS advanced example , when using sam-deploy pipe.

Precisely, you will need advanced example with STACK_PARAMETERS in Advanced examples section ( ) :


  - pipe: atlassian/aws-sam-deploy:1.1.0
      AWS_DEFAULT_REGION: 'us-east-1'
      S3_BUCKET: 'my-s3-bucket'
      STACK_NAME: 'my-stack-name'
      SAM_TEMPLATE: 'sam_template.yaml' <------ your template yaml
          "ParameterKey": "TableName", 
"ParameterValue": ${YOUR_SECRET_ENIRONMENT_VARIABLE} <----- your secured var here


I will repeat, If you don't actually need secret environment vars to pass, you can just hardcode environment variable in Environment section and not use Parameters tool.

But we recommend the safer and more flexible way to be able to secure your lambda environment.


After executing sam-deploy pipe with such template environment variable, lambda function should be created or updated with mentioned environment variables  in the template.

Hope , this explanation is not too vague.

But anyway contact us in the case of more questions or if something did not work.


Regards, Galyna

Suggest an answer

Log in or Sign up to answer
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...

123 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