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:

  1. In the AWS console: create a t3.micro instance from existing UBOS $channel image with name bootstrap-$channel. This instance will be used to create the new installation on a new virtual disk. Follow the wizard.

    Note: t2.micro does not work. Note the availability zone.

  2. 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.

  3. In the AWS console: attach this virtual drive to the bootstrap-$channel instance.

  4. ssh -i <keyfile> shepherd@<ip> into the bootstrap-$channel instance with the appropriate <keyfile> and public IP address.

  5. Update the bootstrap-$channel instance:

    % sudo uboos-admin update
    
  6. On the bootstrap-$channel instance:

    % sudo ubos-install --deviceclass ec2 --channel $channel /dev/nvme1n1 -v
    

    The device names keep changing, so it may not be /dev/nvme1n1.

  7. In the AWS console: detach virtual disk ubos-$channel-YYYYMMDD-I from the EC2 instance bootstrap-$channel.

  8. In the AWS console: create a snapshot from virtual disk ubos-$channel-YYYYMMDD-I, name it ubos-$channel-YYYYMMDD-1 as well.

  9. In the AWS console: create an AMI (“image”) from this snapshot, name it ubos-$channel-YYYYMMDD-1 as well. Make sure “hardware-assisted virtualization” is selected.

Once the image is tested successfully:

  1. Terminate the bootstrap-$channel instance.

  2. Delete its root disk (automatically) and also disk ubos-$channel-YYYYMMDD-I.

  3. Make the AMI public.

  4. Update the AMI identifier on the UBOS website.

The snapshot needs to stay around.

To test the image

  1. 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
      
  2. Log into the instance, execute:

    % sudo ubos-admin status
    
  3. Perform application tests.

  4. Shut down the instance.