Atlassian’s OnDemand products are great. The power of Jira, Bamboo and the likes without the need to maintain a set of servers yourself.

When you sign up for their Bamboo service they provide some ready-made Elastic Instance Image configurations which can be used as a starting point to set up your own build servers. Unfortunately they reside in the US East region and you cannot access them from any other region. I wanted my build servers to be hosted close to home, in the EU (Ireland) region, so I needed to find a way to move them. Since you cannot access the AMIs directly the only option is to create one yourself, based on an existing one.

Preparation

When you set up a new machine using one their AM’s, a new administrator password for your virtual machine is generated at boot time. This password should show up on the details page of the instance on your Bamboo site. The password itself is encrypted in the virtual machine’s System Log. However, sometimes it is possible Bamboo is unable to retrieve the password.

Unable to retrieve password

To be able to decrypt the password from the System Log file you need the private key file. This should be stored on the Bamboo server, but unfortunately it’s impossible to get it when you are using the OnDemand version. Getting the Administrator password is vital because it’s only generated once and if you didn’t configure your starting point to generate one at boot, you will not be able to access your virtual machine easily.

Amazon provides a detailed explanation on how to recover passwords by mounting the virtual machine’s disk onto another virtual machine, editing some configuration files on the disk and attaching it back onto the original virtual machine.

Luckily, when coming from Bamboo, there’s an easier and faster workaround, given that you can start from a fresh instance.

When you first spin up a new Elastic Instance, Bamboo will create a new key pair called elasticbamboo. If this key pair already exists, the existing one will be used to insert the public key onto the newly created virtual machine. So the trick is to create one ourselves and make sure we download the private key file which we can use later on to recover the generated password.

So, head over to the Amazon EC2 Management Console for the US East region and navigate to the Key Pairs page. You can find the link under the Network & Security section in the menu on the left hand side of the page. Delete the existing elasticbamboo key pair if it’s already present.

Create key pair

You should get the request to download the elasticbamboo.pem private key file. Keep this file close, if you lose it there’s no other way to recover it.

Creating Your Base AMI

The first step into creating our base AMI is to start a new ready-made Elastic Instance from within the Bamboo administration section.

In my case I started from the Windows: EBS x86_64 (windows) (stock image) configuration.

Create Elastic Bamboo Virtual Machine

After a few minutes the instance should have been created and the Elastic Agent should be installed.

Elastic Bamboo InstanceInstalled

Navigate back to the Amazon EC2 Management Console, right-click the instance and select Get Windows Password.

Get Windows Password

Choose the elasticbamboo.pem file that was downloaded earlier and decrypt the System Log to get the Administrator password.

Decrypted Password

The next thing to do is to Remote Desktop into the virtual machine and change the Administrator password, or make sure you remember the generated one. I choose to change it.

The next step is to create the base image. Select the EC2 instance, right-click and select Create Image.

Create Image

Fill in a proper name, description and leave the No reboot option unchecked. It will take a few minutes for the AMI status to change from pending to available. When the AMI is available, right-click and select Copy Image. This allows you to select the region to where you want to copy the AMI to.

The final step is to set up a new Elastic Bamboo configuration using our newly created base AMI.