3.3. Uploading a RHEL image to AWS by using the command line


To run a RHEL instance on Amazon Web Services (AWS), you must first upload a RHEL image to AWS. To configure and manage a RHEL EC2 instance on AWS, use the awscli2 utility.

3.3.1. Installing AWSCLI2

You can use the AWS command line interface awscli2 utility to configure and manage RHEL images and Red Hat high availability (HA) cluster on AWS.

Prerequisites

  • You have access to an AWS Access Key ID and an AWS Secret Access Key. For details, see manage access keys.

Procedure

  • Install awscli2:

    # dnf install awscli2

Verification

  1. Verify the installation:

    $ aws --version
    aws-cli/1.19.77 Python/3.6.15 Linux/5.14.16-201.fc34.x86_64 botocore/1.20.77
  2. Configure awscli2 for AWS credentials and settings:

    $ aws configure
    AWS Access Key ID [None]:
    AWS Secret Access Key [None]:
    Default region name [None]:
    Default output format [None]:

3.3.2. Converting and pushing an image to Amazon S3

You can convert a RHEL image in the qcow2 image format to OVA, VHD, VHDX, VMDK, and raw by using the qemu-img utility, and then upload to the Amazon S3 storage. For details, see supported image formats by AWS.

Prerequisites

Procedure

  1. Run qemu-img to convert .qcow2 image to .raw image format:

    # qemu-img convert -f qcow2 -O raw rhel-10.0-sample.qcow2 rhel-10.0-sample.raw
  2. Upload the image to the Amazon S3 bucket:

    $ aws s3 cp rhel-10.0-sample.raw s3://<example-s3-bucket-name>

Verification

3.3.3. Managing a RHEL VM on AWS by using the command line

By using the awscli2 utility, you can manage a RHEL EC2 VM on AWS through command line. In this case, you can use the vmimport role for managing RHEL EC2 image snapshot. With awscli2, you can also import a RHEL EC2 image snapshot, create an AMI, launch, and connect to a RHEL EC2 instance.

  1. Use the vmimport role: An alternate to import the RHEL image to the Amazon S3 bucket is by using the vimport role. See Required permissions for VM Import/Export.
  2. Import RHEL image as a snapshot: You can import RHEL VM image from Amazon S3 as a snapshot to Amazon EC2. For details, see Start an import snapshot task and Monitor an import snapshot task.
  3. Create and launch a RHEL EC2 instance: You can create a RHEL Amazon Machine Image (AMI) from existing snapshot and launch a RHEL EC2 instance. For details, see create an AMI from snapshot by using awscli2 and launching, listing, and deleting RHEL instance by using awscli2.
  4. Configure the private key and connect to the RHEL EC2 instance: You can configure your <example_key>.pem file and connect to an RHEL EC2 instance. For details, see Create a key pair using Amazon EC2 and Connect using the AWS CLI.

3.3.4. Attaching Red Hat subscriptions

Using the subscription-manager command, you can register and attach your Red Hat subscription to a RHEL instance.

Prerequisites

Procedure

  1. Register your system:

    # subscription-manager register
  2. Attach your subscriptions:

  3. Optional: To collect various system metrics about the instance in the Red Hat Hybrid Cloud Console, you can register the instance with Red Hat Lightspeed.

    # insights-client register --display-name <display_name_value>

    For information about further configuration of Red Hat Lightspeed, see Client Configuration Guide for Red Hat Lightspeed.

3.3.5. Setting up automatic registration on AWS gold images

You can deploy Red Hat Enterprise Linux (RHEL) virtual machines faster and more effortlessly on Amazon Web Services (AWS). For that, you must set up gold images of RHEL to be automatically registered to the Red Hat Subscription Manager (RHSM).

Prerequisites

  • You have downloaded the latest RHEL gold image for AWS. For instructions, see Using gold images on AWS.

    注意

    You can only attach an AWS account to a single Red Hat account at a time. Therefore, ensure no other users require access to the AWS account before attaching it to your Red Hat one.

Procedure

  1. Upload the gold image to AWS. For instructions, see one of the following:

  2. Create VMs by using the uploaded image. If your RHSM settings are correct, they will be automatically subscribed to RHSM.

Verification

  • In a RHEL VM created using the above instructions, verify the system is registered to RHSM by executing the subscription-manager identity command. On a successfully registered system, this displays the UUID of the system. For example:

    # subscription-manager identity
    system identity: fdc46662-c536-43fb-a18a-bbcb283102b7
    name: 192.168.122.222
    org name: 6340056
    org ID: 6340056
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部