Preparing Jenkins code
Before we proceed with Jenkins, allow me to introduce the two new helpers – Packer and Serverspec.
Packer
As described:
 | "Packer is a tool for creating machine and container images for multiple platforms from a single source configuration." |  |
 | --https://www.packer.io |
Essentially, Packer is going to, well, pack things for us. We will feed it a template, based on which it will launch an EC2 instance, perform requested tasks (over SSH), then create an AMI from it. Packer can talk to various platforms (AWS, GCE, OpenStack, and so on) to provision resources via local shell, remote (SSH), Salt, Ansible, Chef, and others. As a HashiCorp product, it does not come as a surprise that Packer uses a templating system very similar to Terraform's.
demo-app.json
Here, we define what and how it should be...