Figure 11.19. Configuring an Amazon EC2 slave
You will also need to provide your RSA private key. If you don’t have one, just go to the Key Pairs
menu in the Security Credentials screen and create one. This will create a new key pair for you and
download the private key. Keep the private key in a safe place (you will need it if you want to connect
to your EC2 instances via SSH).
In the advanced options, you can use the Instance Cap field to limit the number of EC2 instances that
Jenkins will launch. This limit refers to the total number of active EC2 instances, not just the ones
that Jenkins is currently running. This is useful as a safety measure, as you pay for the time your EC2
instances spend active.
Once you have configured your overall EC2 connection, you need to define the machines you will
work with. You do this by specifying the Amazon Mirror Image (AMI) identifier of the server image
you would like to start. Amazon provides some starter images, and many more are available from the
community, however not all images will work with EC2. At the time of writing, only certain images
based on 32-bit Linux distributions work correctly.
The predefined Amazon and public AMI images are useful starting points for your permanent virtual
machines, but for the purposes of implementing a dynamic EC2-based cloud, you need to define your
own AMI with the essential tools (Java, build tools, SCM configuration and so forth) preinstalled.
Fortunately, this is a simple process: just start off with a generic AMI (preferably one compatible with
the Jenkins EC2 plugin), and install everything your builds need. Make sure you use an EBS image.
This way, changes you make to your server instance are persisted on an EBS volume so that you don't
lose them when the server shuts down. Then create a new image by selecting the Create Image option
in the Instances screen on the EC2 management console (see Figure 11.20, “Creating a new Amazon