If you know about the version control then you should already know about git and https://bitbucket.org/
If the code of your WordPress website is placed on bitbucket and your website is hosted on Amazon EC2 then it’s best to use bitbucket pipelines to deploy your website from bitucket to AWS EC2. But, it’s not all the sweet as it requires some tips and tricks to get it done. So let’s start it.
Prerequisites
– You should have a EC2 up and running.
– A S3 bucket created
– Set-up IAM Group, User and Role
– Set-up CodeDeploy Application and Deploy Group
– Set repository variables in Bitbucket
To perform all these Prerequisites visit…. https://www.aurigait.com/continuous-deployment-of-react-app-to-aws-ec2-with-bitbucket-pipelines/
WordPress Specific Steps
– Create bitbucket-pipelines.yml in the root folder of your website
– Add following to newly created bitbucket-pipelines.yml
pipelines:
branches:
master:
- step:
script:
- apt-get install -y zip
- zip -r application.zip .
- pipe: atlassian/aws-code-deploy:0.2.7
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
S3_BUCKET: $S3_BUCKET
COMMAND: 'upload'
ZIP_FILE: 'application.zip'
DEBUG: 'true'
- pipe: atlassian/aws-code-deploy:0.2.7
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
DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP
S3_BUCKET: $S3_BUCKET
WAIT: 'true'
COMMAND: 'deploy'
IGNORE_APPLICATION_STOP_FAILURES: 'true'
FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
DEBUG: 'true'
Use this website to validate your bitbucket-pipelines.yml https://bitbucket-pipelines.prod.public.atl-paas.net/validator
– Now create appspec.yml on the root folder of your website
– Add following to newly created bitbucket-pipelines.yml
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html/
permissions:
- object: /var/www/html/
pattern: "*.*"
except: [/var/www/html/ReadMe.txt]
owner: ec2-user
group: wheel
mode: 775
type:
- file
- directory
– Run the Pipeline
Top Tips
– $AWS_DEFAULT_REGION should be us-east-1 (or any other region from https://docs.aws.amazon.com/general/latest/gr/rande.html) NOT include us-east-1a (‘a’ is the culprit) else you will strange errors where event Google will not be able to help 🙁