Run AWS Code Deploy After Successful Build

Issue #16588 resolved
Aftab Naveed
created an issue

Is there a way to automatically Run bitbucket's AWS Code Deploy addon after successful Pipeline build? If not then it would be great to have this feature and we won't have to maintain an additional script to deploy the code.

Thank you.

Comments (5)

  1. Aneita Yang staff

    Hi @Aftab Naveed,

    Thanks for reaching out and for the suggestion.

    Are you specifically interested in using the CodeDeploy addon? You can deploy to AWS CodeDeploy from Pipelines today by configuring an additional step in your pipeline. You can use the Deploy to AWS CodeDeploy guide for more information on how to deploy to CodeDeploy from Pipelines. If maintaining an additional script is what you're trying to avoid, we're currently working on simplifying the configuration experience to deploy to CodeDeploy which might help - with the improvements, we will maintain the configuration to deploy to CodeDeploy. All you will need to do is define some variables so that we can execute the deployment (e.g. your AWS keys and other information specific to your deployment). Does this sound like something that will suit your needs?

  2. Aftab Naveed reporter

    Hi Aneita,

    Thanks for the link I think that is what I am looking for. Just wanted to confirm in order for that script to be executed do I need to have a python installed in my docker container for it to work? How does that script get executed after the pipeline has finished the build?

  3. Aneita Yang staff

    Hey @Aftab Naveed,

    I just found this article on deploying to EC2 with AWS CodeDeploy from Bitbucket Pipelines which you might find helpful.

    To answer your question though, you can configure your bitbucket-pipelines.yml file to look something similar to this:

        - step:
            name: Build
            image: # Your current image
              - # Your current build scripts
        - step:
            name: Deploy 
            image: python:3.5.1
              - apt-get update # required to install zip
              - apt-get install -y zip # required for packaging up the application
              - pip install boto3==1.3.0 # required for
              - zip -r /tmp/ * # package up the application for deployment
              - python # run the deployment script

    You can use a python image for your deploy step, without having to install python into the Docker image that you use for the rest of your build script. The 'Deploy' step will only execute if the earlier steps in the pipeline are successful.

    Hope this helps - let me know if you have any other questions.

  4. Log in to comment