Bitbucket-AWS Codedeploy: Deploy in 2 different folders in 1 EC2 instance

Abryan Manalansang August 12, 2020

I deploy using Bitbucket and AWS CodeDeploy. I have 1 EC2 instance which hosts several websites (staging and production). I also have 2 branches in Bitbucket, develop and master. I configured Bitbucket to deploy to develop and I want the files to go to /var/www/vhosts/staging.com/httpdocs/ directory and when I deploy to master, files should go to /var/www/vhosts/production.com/httpdocs/ directory on the EC2 instance.

I'm only using 1 deployment group.

How can I achieve this?

1 answer

1 accepted

0 votes
Answer accepted
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2020

This is merely a question about AWS CodeDeploy and the docs suggest to make use of multiple deployment groups for the different environments.

The general suggestion is also to not have different environments on the same instance.

However this must not mean that it would not be technically possible. E.g. you can hardencode the environment into the deployment package and when the appspec.yml hooks are fired to take care to copy the application files into the folder of your whish.

From your follow up question it looks to me that you already figured the part out about the deployment groups. Have you managed the different target folders in the life-cycle hooks so far as well? Or did you find a different solution? Please share.

Abryan Manalansang September 8, 2020

I deployed using two different deployment groups. I first send the files in a temporary folder inside the domain (/var/www/vhosts/example.com/temp/) then configured my after_install script to copy those files inside /temp and send the files to the appropriate directories inside the same domain. /var/www/vhosts/example.com/staging.com/ and /var/www/vhosts/example.com/httpdocs/. This is still work in progress btw.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events