A PHP project is set up on bitbucket cloud. The code is developed locally in XAMPP. The code runs in Amazon Web Service Elastic Beanstalk environment.


I commit my changes locally and then push to Bitbucket. Now I need to deploy from Bitbucket to the AWS Elastic Beanstalk instance.

I don't want any other tools to be used in-between to do this nor use the zip file to upload to Elastic Beanstalk. Instead perform directly from Bitbucket to Elastic Beanstalk. How can I do this?


I've had a similar issue, needing to deploy to Elastic Beanstalk from Bitbucket. While mine is a Python application, the following is language-agnostic.

  • Use Bitbucket pipelines to zip up your code and drop it into a versioned S3 bucket (versioning is important here)
  • Create a pipeline in AWS CodePipeline to pick up the zip file from the S3 bucket Bitbucket has just dropped the bundle into. AWS CP will use the versioning notification topic that's silently published within AWS's systems to automatically trigger.
  • Set the pipeline's deployment phase to be your Elastic Beanstalk environment.

I've been using this method for a while now and not really had a problem with it. We have other sections that belong to both Bitbucket's and AWS's Pipeline (testing and building docker images), but this method should work just fine without the "build" phase in CodePipeline.


There does not seem to be a solution that lets you deploy directly from Bitbucket to Elastic Beanstalk.

However, if you are using a git repository on Bitbucket you can deploy directly from your command line interface to Elastic Beanstalk.

This is accomplished by using the EB CLI in conjunction with Git.



Use bitbucket pipelines to create a procedure that when pushed to a branch, it installs the eb commands to the pipeline then uses eb command prompts to deploy the site to the correct environment.


Maybe this wasn't possible two years ago, but it's easy now. Set up your Elastic Beanstalk environment (using dummy or example code if you need to). Then in BitBucket, add your AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION as Repository Variables, and add eb cli steps in your bitbucket-pipelines.yml to deploy.

The exact pipeline steps depend on your application, environment variables, etc. but it could be as simple as

image: php:7.2.11

      - step:
        - eb init my-elastic-beanstalk-app -p php
        - eb deploy my-elastic-beanstalk-environment

There is another example at https://github.com/loonpwn/harlanzw.com/blob/master/bitbucket-pipelines.sample.yml


Bitbucket team has been adamant that they would not provide any solutions. They rather suggested to refer google. I hear only excuses from the team not an answer. Its a shame.

The answer is there is no solution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.