简体   繁体   中英

How do I start an Amazon EC2 VM from a saved AMI using Jenkins?

I'm trying to create a Jenkins job to spin up a VM on Amazon EC2 based on an AMI that I currently have saved. I've done my searching and can't find an easy way to do this other than through Amazon's GUI. This isn't very ideal as there are a lot of manual steps involved and it's time-consuming.

If anyone's had any luck doing this or could point me in the right direction that would be great.

Cheers, Darwin

Unless I'm misunderstanding the question this should be possible using the cli, assuming you can install and configure the cli on your jenkins server you can just run the command as a shell script as part of the build.

Create an instance with CLI.

The command would be something along the lines of:

[path to cli]/aws ec2 run-instances --image-id ami-xyz 

If your setup is too complicated for a single cli command, I would recommend creating a simple cloudformation template .

If you are unable to install the cli, you could use any number of sdk's eg java to make a simple application you could run with jenkins.

There is the Jenkins EC2 Plugin

Looking at the document it looks like you may be able to reuse your AMI. If not, you can configure it with an init script

Next, configure AMIs that you want to launch. For this, you need to find the AMI IDs for the OS of your choice. ElasticFox is a good tool for doing that, but there are a number of other ways to do it. Jenkins can work with any Unix AMIs. If using an Ubuntu EC2 or UEC AMI you need to fill out the rootCommandPrefix and remoteAdmin fields under 'advanced'. Windows is currently unsupported.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM