Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Configuring AWS Pipelines

01 Feb 2019 »

AWS Pipeline

After the second deploy of the blog site, I was tired of deploying and I wanted something to automate my deploys when I pushed any new code to the master branch. I used a git2s3 quickstart template to set this up and then CloudWatch to start my deployment pipeline.

Source Configuration in AWS Pipeline

Step through the pipeline setup using S3 as the provider for the pipeline. Make sure the bucket points to the correct s3 bucket. I’ve made the mistake of pointing to the wrong bucket and had to re-configure the pipeline. The S3 object key is a little complex, but it’s not too difficult; I had to enter the bucket name in manually.

Code Deploy

Code pipeline will then cut you off and tell you to create a CodeDeploy application. The deployment group name is a name (for this instance is website-devops-itsltns-io), the deployment type is in-place, the rollback is enabled, and the ARN is a role from a previous deploy website-itsltns-io-codedeploy-role.

After CodeDeploy is configured in AWS’s environment, you will need to add the appropriote appspec.yml file to the project root of your application to ensure the project is installed on the server properly. This is a key step to making sure the deploy works on the server!

As an example our appspec.yml looks like this to deploy the devops blog:

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html/devops.itsltns.io
hooks:
  BeforeInstall:
    - location: scripts/install_dependencies
      timeout: 300
      runas: root
    - location: scripts/start_server
      timeout: 300
      runas: root
  AfterInstall:
    - location: scripts/reload_server
      timeout: 300
      runas: root
  ApplicationStop:
    - location: scripts/stop_server
      timeout: 300
      runas: root

The location scripts/ is located in our project root. Inside the folder is a collection of bash scripts that are used to install dependencies and ensure the server is configured properly.

todo May want to go back and change the install scripts for the jekyll blog to add the nginx conf file rather than having to manually add the nginx config code and ssh into the server.. Not a problem for right now as scale and permissions are managed by one man, me. I would also like to get blue-green deployments working soon as well to reduce downtime between deploys.

Create Pipeline

After creating the pipeline, release a change manually and check if it works. It should deploy successfully and the code should be deployed on the server.

After the deployment is done, check on the machine to see if everything is configured and the code is in the correct location.

From this point, I manually configured the nginx server, but in the future and for blue-green deploys, I would like this to automatically send over nginx .conf files.

Conclusion

Although this was a brief post, the key components were covered enough to get a basic deploy pipeline created for a static blog running on an nginx server. Most of AWS’s interface is easy to navigate and they provide good documentation for getting these services up and working. Complex setups can be difficult to configure, but we will look more into these when deploying with Rails in the near future.

© Jack Moore