DEV Community

Discussion on: AWS DevOps Pro Certification Blog Post Series: Code Deploy

Collapse
 
andrewbrown profile image
Andrew Brown 🇨🇦

Debugging CodeDeploy

Most of the trouble with CodeDeploy is debugging scripts. So the best way to save lots of time is ssh into an EC2 Instance of your AMI you plan to use for CodeDeploy and assume root user:

sudo su

and then run all your commands you want in your scripts with absolute paths so for example

sudo su - ec2-user -c 'cd /home/ec2-user/app; /home/ec2-user/.rvm/gems/ruby-2.4.4/wrappers/bundle install --without development test`

Make Sure to rebake your AMI so ApplicationStop runs

When I was deploying I noticed my services were not stopping and staring correctly and after much frustration the issue was that in order for ApplicationStop to run there has to be a history of a previous deploy on the instance because for ApplicationStop it will reference the previous deploy.

However if you are using Blue/Green Deployment its always launching a new instance and the AMI I had did not have baked into it a previous deploy so it would never run ApplicationStop. So I rebaked my AMI so it had a reference to previous deploy.