Chapter 5. Creating and uploading a customized RHEL system image to Amazon Web Service using Red Hat Image Builder

The ability to create customized RHEL system images by using Red Hat Image Builder and upload those images to the Amazon Web Services (AWS) target environment is available.

5.1. Creating and uploading a customized RHEL system image to AWS using Image Builder

Follow the steps to create customized system images using Red Hat Image Builder and upload those images to Amazon Web Services (AWS).

Prerequisites

Procedure

  1. Access Red Hat Image Builder on the browser of your choice.

    You are redirected to the Red HatImage Builder dashboard.

  2. Click Create image.

    A Create a new image dialog window opens.

  3. In the Image output window:

    1. From the dropdown menu, select the Release: Red Hat Enterprise Linux (RHEL) 8.3.
    2. Select Amazon Web Services as the target environment.

      Click Next.

  4. In the Target Environment- Upload to AWS window, enter your AWS account ID.

    Click Next.

Your image will be uploaded to Amazon Web Services and shared with the account ID you entered. You can find your AWS account ID by accessing the option My account on the AWS console. Click Next.

  1. In the Registration window, you have the option to:

  2. Optional: In the Additional package window, add packages to your image. See Chapter 4, Adding packages during image creation by Using Red Hat Image Builder.
  3. In the Review window, review the details about the image creation and click Create.

    Red Hat Image Builder starts the compose of a RHEL 8.3 AMI image for the x86_64 architecture and uploads it to AWS EC2. Then, it will share the AMI with the account you specified.

    The Red Hat Image Builder Images dashboard opens. You can see details such as the Image UUID, the cloud target environment, the image OS release and the status of the image creation. Once the status is Ready, the Azure Disk Image is shared with the specified account.

    Possible statuses:

    • Pending: the image upload and cloud registration is being processed.
    • In Progress: the image upload and cloud registration is ongoing.
    • Ready: the image upload and cloud registration is completed
    • Failed: the image upload and cloud registration failed.

      Note

      The image build, upload and cloud registration processes can take up to ten minutes to complete.

Verification

  • Check if the image status is Ready. It means that the image upload and cloud registration is completed successfully.

5.2. Accessing your customized RHEL system image for AWS from your account

After the image is built, uploaded, and the cloud registration process status is marked as Ready, you can access the Amazon Web Services (AWS) image you created and shared with your AWS EC2 account.

Prerequisites

Procedure

  1. Access your AWS account and navigate to Service→EC2.
  2. In the upper right menu, verify if you are under the correct region: us-east-1.
  3. In the left side menu, under Images, click AMIs.

    The dashboard with the Owned by me images opens.

  4. From the dropdown menu, choose Private images.

    You can see the image successfully shared with the AMI account you specified.

5.3. Launching your customized RHEL system image for AWS from your AWS EC2

You can launch the image you successfully shared with the AWS EC2 account you have specified. To do so, follow the steps:

Prerequisites

Procedure

  1. From the list of images, select the image you want to launch.
  2. On the top of the panel, click Launch. You are redirected to the Choose an Instance Type window.
  3. Choose the instance type according to the resources you need to launch your image. Click Review and Launch.
  4. Review your instance launch details. You can edit each section, such as Security, Storage, for example, if you need to make any change. Once you finish the review, click Launch.
  5. To launch the instance, you must select a public key to access it.

    Create a new key pair in EC2 and attach it to the new instance.

    1. From the drop-down menu list, select Create a new key pair.
    2. Enter the name to the new key pair. It generates a new key pair.
    3. Click Download Key Pair to save the new key pair on your local system.
  6. Then, you can click Launch Instance to launch your instance.

    You can check the status of the instance, it shows as Initializing.

  7. Once the instance status is running, the Connect button turns available.
  8. Click Connect. A popup window appears with instructions on how to connect using SSH.

    1. Select the preferred connection method to A standalone SSH client and open a terminal.
    2. In the location you store your private key, make sure that your key is publicly viewable for SSH to work. To do so, run the command:

      $ chmod 400 <your-instance-name.pem>
    3. Connect to your instance using its Public DNS:

      $ ssh -i "<_your-instance-name.pem_"> ec2-user@<_your-instance-IP-address_>
    4. Type yes to confirm that you want to continue connecting.

As a result, you are connected to your instance using SSH.

Verification

  • From a terminal, check if you are able to perform any action while connected to your instance using SSH.

5.4. Copying your customized RHEL system image for AWS to a different region on your AWS EC2

You can copy the image you successfully shared with the Amazon Web Services EC2 to your own account. Doing so, you grant that the image you shared and copied is available until you delete it, instead of expiring after some time. To copy your image to your own account, follow the steps:

Prerequisites

Procedure

  1. From the list of Public images, select the image you want to copy.
  2. On the top of the panel, click Actions.
  3. From the dropdown menu, choose Copy AMI. A popup window appears.
  4. Choose the Destination region and click Copy AMI.

Once the copying process is complete, you are provided with the new AMI ID. You can launch a new instance in the new region. See Section 5.3, “Launching your customized RHEL system image for AWS from your AWS EC2”

Note

When you copy an image to a different region, it results in a separate and new AMI in the destination region, with a unique AMI ID.