Amazon Web Services EC2
/docs/linux/developer/cloud-images/amazon-ec2/
Prerequisites
Use a Device running UBOS Linux.
Install the needed packages:
% sudo pacman -S ubos-gears-cloud ubos-gears-cloud-aws
Create a file that defines the default cloud you will be using to create the image.
By default, it is named default-cloud.json and has content:
{
"type" : "AwsCloud",
"region": "us-east-1",
"aws-access-key-id" : "<<Your AWS access key id>>",
"aws-secret-access-key" : "<<Your AWS secret access key>>",
"ssh-public-key": "<<Public SSH key>>",
"ssh-private-key": "<<Private SSH key>>"
}
Notes:
- The AWS keys and secrets are needed to invoke AWS operations, such as creating the instance that will be used to create the image, and the image itself.
- The SSH keys are used to access the temporary instance that will be used to create the instance. They are not used for the created image.
To create the image
% ubos-gears-cloud createimage
The createimage subcommand understands many options. Add --help to the command to learn more.
Alternative: manual process (being obsoleted)
To create a UBOS image for EC2 on the $channel Release Channel:
-
In the AWS console: create a
t3.microinstance from existing UBOS$channelimage with namebootstrap-$channel. This instance will be used to create the new installation on a new virtual disk. Follow the wizard.Note:
t2.microdoes not work. Note the availability zone. -
In the AWS console: create new virtual 16GB EBS Volume in the same availability zone, name it
ubos-$channel-YYYYMMDD-I, with the current date and an index. -
In the AWS console: attach this virtual drive to the
bootstrap-$channelinstance. -
ssh -i <keyfile> shepherd@<ip>into thebootstrap-$channelinstance with the appropriate<keyfile>and public IP address. -
Update the
bootstrap-$channelinstance:% sudo uboos-admin update -
On the
bootstrap-$channelinstance:% sudo ubos-install --deviceclass ec2 --channel $channel /dev/nvme1n1 -vThe device names keep changing, so it may not be
/dev/nvme1n1. -
In the AWS console: detach virtual disk
ubos-$channel-YYYYMMDD-Ifrom the EC2 instancebootstrap-$channel. -
In the AWS console: create a snapshot from virtual disk
ubos-$channel-YYYYMMDD-I, name itubos-$channel-YYYYMMDD-1as well. -
In the AWS console: create an AMI (“image”) from this snapshot, name it
ubos-$channel-YYYYMMDD-1as well. Make sure “hardware-assisted virtualization” is selected.
Once the image is tested successfully:
-
Terminate the
bootstrap-$channelinstance. -
Delete its root disk (automatically) and also disk
ubos-$channel-YYYYMMDD-I. -
Make the AMI public.
-
Update the AMI identifier on the UBOS website.
The snapshot needs to stay around.
To test the image
-
Instantiate the image into a “t3” “micro” instance. Note: “t2” does not work.
-
Either perform this operation through the AWS website, or:
-
Perform this operation from your Device with:
% ubos-gears-cloud createdevice --imageid <imageid>To determine the available images and their image ids, run:
% ubos-gears-cloud listimages
-
-
Log into the instance, execute:
% sudo ubos-admin status -
Perform application tests.
-
Shut down the instance.