Next, I outlined the process of creating a CentOS 4.7 AMI.
Finally, I'm going to show how to upload, register and start the instance. I shouldn't have to say, though I will, there are numerous variations on how to perform all of these tasks and getting your system and application in the cloud.
I'm my last installment I created the image itself on my server. After doing so, it needs to be broken up into smaller chunks to be uploaded and create a manifest. This is done with one command ec2-bundle-image.
ec2-bundle-image \NOTE: If you do not have the EC2_PRIVATE_KEY or EC2_CERT shell variables then you didn't follow my instructions in my first post.
-k $EC2_PRIVATE_KEY \
--cert $EC2_CERT \
--user 123412341234 \
-i centos-4.7-i386.img \
-r i386 \
-B "ami=sda1,root=/dev/sda1,swap=sda3"
There are some obvious options here that are necessary. -B for block device maps and -r specifying the architecture but there are a few others that may be useful. --kernel to specify the kernel ID to boot with and --ramdisk in case one is needed.
NOTE: I should mention, at this point that if the system you're working on has a system clock that is too far off with Amazon's then you may receive the message
Client.InvalidSecurity: Request has expiredBest bet is to get your system's NTP service running, such as ntp(8), for details on synchronizing your systems clock.
Uploading the chucks...
You'll need your access key and secret key at this point for the -a and -s parameters below. Amazon S3 stores your files in what they call buckets. Every file in the bucket must have a unique name. I'm not 100% on this but the bucket name needs to be alphanumeric and can also use periods. Beyond that, I'm not sure. For more information on the full S3 API and it's capabilities and constraints, check out the Amazon S3 documentation pages.
OK. We're uploading. The chunkified image and manifest must be sent to a bucket (-b) in the S3 storage cloud.
ec2-upload-bundle \In this case, the full path to the files will have the form
-b my.first.centos.4.7 \
-m /tmp/centos-4.7-i386.img.manifest.xml \
-a "sssssshhhhhh" \
-s "itsre/allyr/eally/secret"
my.first.centos.4.7/centos-4.7-i386.img.manifest.xmlSimple. Oh, if the files (they're not an AMI yet) aren't in use and you want to delete them check out the ec2-delete-bundle. There is help available online as well by using the --help command line option.
The files are in the storage cloud but the EC2 service needs to know about it. To do so, it needs the path to the manifest file. Registering is simple
ec2-register \Conversely, when you get bored with your image and want to eventually remove it from S3 (so you don't get charged every month) there is a ec2-unregister command. Again, like most or all EC2 commands in the toolkit, you may use the --help command line option.
-K $EC2_PRIVATE_KEY \
-C $EC2_CERT \
my.first.centos.4.7/centos-4.7-i386.img.manifest.xml
A listing of all AMI's are available using the command below or by using Elasticfox, the web browser extension for Firefox that provides a GUI for
ec2-describe-imagesThe security group used will be your "default" policy. Since we're expecting to connect to the instance via SSH we ought to enable port 22/tcp.
IMAGE ami-89abcdef my.first.centos.4.7/centos-
4.7-i386.img.manifest.xml 495219933132 available private
ec2-authorize default -P tcp -p 22 -s 0.0.0.0/0NOTE: Keep this command in mind. Depending on what you intend to do with your server in the cloud, additional ports may need to be opened.
Finally, we can start the AMI. By default, the m1.small instance type will be used providing the instance with a 1 core processor and roughly 1.7 GB of memory. You can start as many as you like.
ec2-run-instances \Use the ec2-describe-instances to check the instance and once it's running the output will contain the IP address assigned to it. Earlier, we opened port 22 so starting a SSH connection now should work just fine. Log in and check out your server in the cloud.
-K $EC2_PRIVATE_KEY \
-C $EC2_CERT \
ami-89abcdef
If you find the m1.small lacking in memory or horsepower, other instance types with more cores and memory are available. I'd recommend starting with m1.small and if it isn't working, shut down the instance and bring it back up with a different type such as m1.large or c1.medium. There are described on the AWS web site.
All commands are well documented using the command line --help as well as on the AWS web site
That's all I have for now.