Chapter 6. Creating and uploading a customized RHEL system image to Amazon Web Service using Red Hat Image Builder
You can create customized RHEL system images using Red Hat Image Builder, and upload those images to the Amazon Web Services (AWS) target environment.
6.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
- You have an AWS account created.
- You have a Red Hat account. Access Portal.
Procedure
Access Red Hat Image Builder on the browser.
The Red Hat Image Builder dashboard appears.
Click Create image.
The Create image dialog wizard opens.
On the Image output page, complete the following steps:
- From the Release list, select the Release that you want to use: for example, choose Red Hat Enterprise Linux (RHEL).
From the Select target environments option, select
Amazon Web Services
as the target environment.Click Next.
On the Target Environment - Amazon Web Service page, enter your AWS account ID and click Next.
You can find your AWS account ID by accessing the option Account on the AWS console.
On the Registration page, select the type of registration that you want to use. You can select from these options:
- Register images with Red Hat - Register and connect image instances, subscriptions and insights with Red Hat. For details on how to embed an activation key and register systems on first boot, see Chapter 3, Creating a customized system image with an embed subscription using Red Hat Image Builder.
- Register image instances only - Register and connect only image instances and subscriptions with Red Hat.
Register later - Register the system after the image creation.
Click Next.
- Optional: On the Packages page, add packages to your image. See Chapter 4, Adding packages during image creation by Using Red Hat Image Builder.
- On the Name image page, enter a name for your image and click Next. If you do not enter a name, you can find the image you created by its UUID.
On the Review page, review the details about the image creation and click Create image.
After you complete the steps in the Create image wizard, the Image Builder dashboard is displayed.
Red Hat Image Builder starts the compose of a RHEL Amazon Machine Image (AMI) for the
x86_64
architecture and uploads it to AWS EC2. Then, it will share theAMI
image with the account you specified.On the dashboard, you can see details such as the Image UUID, the cloud target environment, the image OS release and the status of the image creation.
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.
NoteThe 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.
NoteThe image artifacts are saved for 14 days and expire after that. Ensure to transfer the image to your account to avoid losing it.
6.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
- You have access to your AWS Management Console.
Procedure
- Access your AWS account and navigate to Service→EC2.
-
In the upper right menu, verify if you are under the correct region:
us-east-1
. In the left side menu, under Images, click AMIs.
The dashboard with the Owned by me images opens.
From the dropdown menu, choose Private images.
You can see the image successfully shared with the AWS account you specified.
6.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
- You have access to your customized image on AWS. See Accessing your customized RHEL system image for AWS from your account.
Procedure
- From the list of images, select the image you want to launch.
- On the top of the panel, click Launch. You are redirected to the Choose an Instance Type window.
- Choose the instance type according to the resources you need to launch your image. Click Review and Launch.
- Review your instance launch details. You can edit each section, such as Security, Storage, for example, if you need to make any changes. After you finish the review, click Launch.
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.
- From the drop-down menu list, select Create a new key pair.
- Enter the name to the new key pair. It generates a new key pair.
- Click Download Key Pair to save the new key pair on your local system.
Then, you can click Launch Instance to launch your instance.
You can check the status of the instance, it shows as Initializing.
- After the instance status is running, the Connect button turns available.
Click Connect. A popup window appears with instructions on how to connect using SSH.
- Select the preferred connection method to A standalone SSH client and open a terminal.
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>
Connect to your instance using its Public DNS:
$ ssh -i "<_your-instance-name.pem_> ec2-user@<_your-instance-IP-address_>"
- 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.
6.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
- You have access to your customized image on AWS. See Accessing your customized RHEL system image for AWS from your account
Procedure
- From the list of Public images, select the image you want to copy.
- On the top of the panel, click Actions.
- From the dropdown menu, choose Copy AMI. A popup window appears.
Choose the Destination region and click Copy AMI.
After the copying process is complete, you are provided with the new AMI ID. You can launch a new instance in the new region. See Launching your customized RHEL system image for AWS from your AWS EC2
NoteWhen 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.
6.5. Sharing your AWS images to a different region
You can share the images you create to different regions and therefore access the same image in more regions, creating more images from a build with the exact same content. After the images status becomes Ready
, you can start your instance to the AWS selected region. To push the image to a different region or regions, follow the steps:
Prerequisites
- You created an AWS image.
Procedure
-
From the
Image Builder
table, select the AWS image you want to upload to a different region. From the
Node options icon (⫶)
, selectShare to new region
. AShare to new region
wizard opens.-
From the
Select region
dropdown menu, choose the region or regions to upload your image. ClickShare
.
-
From the
After the images status becomes Ready
, you can start your new instance to the AWS selected region.
Verification
-
Click the
Node options icon (⫶)
and select an AWS region to start the image. -
The
Image Builder
table shows the image or images build status that you shared to the new region or regions.
Additional resources