Finally, it’s time to demonstrate our CI/CD environment in a practice. If you successfully configured the CodePipeline from the last post, you can see that it automatically build the RPM package and deploy it on our server. This is the very simplified scenario because in the real world you will add more stages mainly for testing purposes. Tests are very important in CI/CD and are probably the most challenging part of this configuration. However, for the purpose of our demo, the current setup is sufficient and should demonstrate to you the overall idea and workflow.

cd17

Go to AWS console and CodePipeline service. Click on our previously created CodePipeline RPM-Deployment. You should see that all stages are successfully completed, with the time of last execution.

cd18

You can find here more interesting facts. For example, the commit number used for this deployment. You can simply switch to CodeBuild details to see the logs. It also allows you to quickly access the latest deployment details. You also see the history of your deployments. Moreover, you can also modify your current workflow by adding more stages. Let’s say you want to add another stage Test. AWS allows you to do this, using a simple GUI interface.

cd19

Let’s check if our package has been installed on the server and see the results. Login to your EC2 instance used for deployment. You should see your modified MOTD message.

cd20

Further investigation shows, that our rpm is installed and /etc/motd modified.

cd21

Let’s do a quick test, and modify our code by changing the MOTD message and rpm version in the spec file. Then save it and push to the GIT repository.

$ cd rpmbuild
$ mkdir motd-1.1
$ echo "THIS IS MY NEW MOTD. DEPLOYED AUTOMATICALLY USING CodePipeline" > motd-1.1/motd
$ tar -czvf SOURCES/motd-1.1.tar.gz motd-1.1
$ rm -rf motd-1.1
$ vi SPEC/motd.spec

### Change below lines ###
Version:	1.1

:wq!

$ git add .
$ git commit -m "MOTD version 1.1"
$ git push origin master

Once you pushed a new update to CodeCommit, CodePipeline will automatically detect the change and trigger the build process. You can see the progress in CodePipeline dashboard.

cd23

After a couple of minutes, when the CodePipeline finishes its job, go to your EC2 instance and check the content of /etc/motd as well as RPM version.

cd22

WOW!! New RPM has been automatically installed on the system :) I hope you like the way CI/CD works. I strongly encourage you to deeper tests and playing around these amazing tools provided by AWS.

That’s all for CI/CD part for now. I hope you enjoyed it. The original code used for this tutorial can be found at my GitHub https://github.com/mycloudfun/devops-aws.

If you have any questions, please comment here or leave me a message.

Thank you!