My site is now deployed with AWS CI/CD

This is a test post of my new deployment. I have implemented AWS CodeCommit for storing the site files and to utilize source control. CodeBuild to build out the Hugo files and publishing to S3. Then having CodePipeline to trigger the build, when it detects a change from CodeCommit.

Update 1: After messing around with the buuildspec.yml file, I was able to get CodeBuild and CodePipeline to complete a build successfully. I also realized that I needed to publish the files locally first by running hugo -v. Some reason when CodePipeline triggered, it failed on the build step. It didn’t like the hugo -v in the buildspec file, so I had to take it out. Then push the changes to CodeCommit. For reference here is the buildspec.yml file for CodeBuild:

version: 0.2

environment_variables:
  plaintext:
    HUGO_VERSION: "0.69.0"
    
phases:
  install:
    runtime-versions:
      docker: 18
    commands:                                                                 
      - cd /tmp
      - wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz
      - tar -xzf hugo_${HUGO_VERSION}_Linux-64bit.tar.gz
      - mv hugo /usr/bin/hugo
      - cd - 
      - rm -rf /tmp/*
  build:
    commands:
      - aws s3 sync ./public s3://rudyr.com
  post_build:
    commands:
      - echo Build completed on `date`
artifacts:
  files:
    - '**/*'
  base-directory: public

Update 2: I can successfully now push changes to CodeCommit. Then have CodePipeline automatically detect changes to trigger CodeBuild. I’m liking this new setup. It was a fun project to do a deep dive into AWS CI/CD offerings.

AWS  DevOps 

comments powered by Disqus