Bitbucket Pipeline with AWS EB and Wordpress

Akkireddy
2 min readNov 12, 2021

By Elastic Beanstalk, you can quickly deploy and manage applications in the AWS Cloud without worrying about the infrastructure that runs those applications.

Steps:

  1. create a repository on the bitbucket with Wordpress code in it or you can use the existing repository.
  2. Then you need enable the pipeline from the bitbucket if it is not already enabled. To enable the pipeline you need to go to your
    repository settings->Pipeline setting->Enable piplines
  3. Then you can go to the pipelines from the repository to write the YAML configuration for the pipeline or you can create the file from your editor as bitbucket-pipelines.yml and commit that file to the repository.

I suppose you already have the beanstalk environment in your AWS account if not create it for the PHP application.

Then just copy the below code, put it in bitbucket-pipelines.yml and replace it with the appropriate variables from your AWS account and make sure indentation is correct.

Basic usage variables

  • AWS_ACCESS_KEY_ID (*): Your AWS access key.
  • AWS_SECRET_ACCESS_KEY (*): Your AWS secret access key.
  • AWS_DEFAULT_REGION (*): The AWS region code (us-east-1, us-west-2, etc.) of the region containing the AWS resource(s). For more information, see Regions and Endpoints.
  • APPLICATION_NAME (*): The name of the Elastic Beanstalk application.
  • COMMAND (*): Command to be executed during the deployment. Valid options are all, upload-only, deploy-only. Default: all.
  • ENVIRONMENT_NAME (*): Environment name.
  • ZIP_FILE (*): The application source bundle to deploy (zip, jar, war).
  • S3_BUCKET: Bucket name used by Elastic Beanstalk to store artifacts. Default: ${APPLICATION_NAME}-elasticbeanstalk-deployment}
  • VERSION_LABEL: Version label for the new application revision. Default: ${ENVIRONMENT_NAME}_${BITBUCKET_COMMIT:0:8}_YYYY-mm-dd_HHMMSS).
  • WAIT: Wait for deployment to complete. Default: false.
  • WAIT_INTERVAL: Time to wait between polling for deployment to complete (in seconds). Default: 10.
  • DEBUG: Turn on extra debug information. Default: false.
  • (*) = required variable.

Note: Deploy your version deploy-$BITBUCKET_BUILD_NUMBER-multiple into the environment production and wait until the deployment to complete.

Example

image: atlassian/default-image:2

pipelines:
branches:
staging:
- step:
caches:
- composer
script:
- apt-get update
- apt-get install -y zip
- zip -r application.zip .
- pipe: atlassian/aws-elasticbeanstalk-deploy:1.0.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
APPLICATION_NAME: $APPLICATION_NAME
ENVIRONMENT_NAME: $ENVIRONMENT_NAME
S3_BUCKET: $S3_BUCKET
ZIP_FILE: 'application.zip'
VERSION_LABEL: 'app-$BITBUCKET_BUILD_NUMBER
WAIT: 'true'

--

--

Akkireddy

#DevOps — #AWS — #Cloud enthusiast.. Views are my own.