For the past few hours I have been battling with trying to create a script to bundle a running EC2 instance. After many, S3 access denied, errors, “Error talking to S3: Server.OperationAborted(409): A conflicting conditional operation is currently in progress against this resource. Please try again.” errors, and “you are trying to upload to a different region than you are bundling in errors, I think I finally have it.

The key is to just allow the script to create the bucket. I used s3fox to create the bucket, and it built it for no region. Performing a manifest migration solved one problem, but after that one was solved, I still kept getting the error. After I deleted the bucket, and changed the name of the bucket in the script, it was still giving me the “OperationAborted” issue. After a bunch of trying, this script got me to the gold.

Another super important thing was to ( I use ubuntu ) perform an apt-get ec2-ami-tools to make sure you have the ec2-register installed. It will install java as a result, but will not set the JAVA_HOME environment variable. It just wants to be able to find the binary so I added the export JAVA_HOME=/usr. Java is in /usr/bin/java.

After everything is up, you’ll still have quite the mess in your /mnt folder, but I wrote a cleanup script to deal with that.