Chapter 2. Installing RHEL AI on AWS
There are 2 ways you can install and deploy Red Hat Enterprise Linux AI on AWS:
- You can purchase RHEL AI from the AWS marketplace.
-
You can download the RHEL AI
x86_64RAW file from the Download Red Hat Enterprise Linux AI page and convert it to an Amazon Machine Image (AMI), and install using the AMI.
2.1. Converting the RHEL AI RAW image to an AMI Copy linkLink copied to clipboard!
Before deploying RHEL AI on an AWS machine, you must set up an Amazon S3 bucket, convert the RHEL AI image to an Amazon Machine Image (AMI), and create the following resources:
- S3 bucket with the RHEL AI image
- AWS EC2 snapshot
- AWS AMI
- AWS instance
Prerequisites
- You have configured an access key ID in the AWS IAM account manager.
- You have installed the AWS CLI. For more information, see Installing or updating to the latest version of the AWS CLI.
Procedure
Create an S3 bucket and set the permissions to allow image file conversion to AWS snapshots.
Create the necessary environment variables. Open a shell prompt and run the following commands:
$ export BUCKET=<CUSTOM_BUCKET_NAME> $ export RAW_AMI=nvidia-bootc.ami $ export AMI_NAME="rhel-ai" $ export DEFAULT_VOLUME_SIZE=1000Create the S3 bucket by running the following command:
$ aws s3 mb s3://$BUCKETCreate the
trust-policy.jsonfile with the necessary configuration for generating an S3 role for your bucket:$ printf '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "vmie.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:Externalid": "vmimport" } } } ] }' > trust-policy.jsonCreate the S3 role for your bucket. Run the following command:
$ aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.jsonCreate the
role-policy.jsonfile with the necessary configurations for generating a policy for your bucket:$ printf '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::%s", "arn:aws:s3:::%s/*" ] }, { "Effect": "Allow", "Action": [ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource": "*" } ] }' $BUCKET $BUCKET > role-policy.jsonCreate the policy for your bucket by running the following command:
$ aws iam put-role-policy --role-name vmimport --policy-name vmimport-$BUCKET --policy-document file://role-policy.json
Copy the
x86_64RAW image URL from the Download Red Hat Enterprise Linux AI page and download the image usingcurl:$ curl -Lo disk.raw.gz <RAW_IMAGE_URL>Unzip the
raw.gzfile:$ gunzip disk.raw.gzUpload the image to the S3 bucket with the following command:
$ aws s3 cp disk.raw s3://$BUCKET/$RAW_AMIConvert the image to a snapshot and store it in the
TASK_IDvariable name by running the following commands:$ printf '{ "Description":"rhelai-image", "Format":"raw", "UserBucket":{ "S3Bucket":"%s", "S3Key":"%s" } }' $BUCKET $RAW_AMI > containers.json$ TASK_ID=$(aws ec2 import-snapshot --disk-container file://containers.json | jq -r .ImportTaskId)Follow the progress of the disk image to snapshot conversion job with the following command:
$ aws ec2 describe-import-snapshot-tasks --filters Name=task-state,Values=activeGet the snapshot ID and store it the
SNAPSHOT_IDvariable by running the following command:$ SNAPSHOT_ID=$(aws ec2 describe-import-snapshot-tasks | jq -r '.ImportSnapshotTasks[] | select(.ImportTaskId=="'${TASK_ID}'") | .SnapshotTaskDetail.SnapshotId')Add a tag name to the snapshot by running the following command:
$ aws ec2 create-tags --resources $SNAPSHOT_ID --tags Key=Name,Value="$AMI_NAME"Register the AMI from the snapshot with the following command:
$ AMI_ID=$(aws ec2 register-image \ --name "$AMI_NAME" \ --description "$AMI_NAME" \ --architecture x86_64 \ --root-device-name /dev/sda1 \ --block-device-mappings "DeviceName=/dev/sda1,Ebs={VolumeSize=${DEFAULT_VOLUME_SIZE},SnapshotId=${SNAPSHOT_ID}}" \ --virtualization-type hvm \ --ena-support \ | jq -r .ImageId)Add a tag name to identify the AMI by running the following command:
$ aws ec2 create-tags --resources $AMI_ID --tags Key=Name,Value="$AMI_NAME"
2.2. Deploying on AWS using the CLI Copy linkLink copied to clipboard!
You can launch the Red Hat Enterprise Linux AI AWS instance by using the RHEL AI Amazon Machine Image (AMI) from the AWS web console or by using the awscli CLI.
The following procedure describes how to use the awscli CLI to launch the AWS instance with the custom AMI.
Prerequisites
- You have created the RHEL AI AMI.
-
You have installed the awscli CLI, and configured it with your
aws_access_key_idandaws_secret_access_keyvariables. - You have configured your Virtual Private Cloud (VPC).
- You have created a subnet for your instance.
- You have created an SSH key pair.
- You have created an AWS security group on.
Procedure
Configure the various AWS parameters.
Set the
AMIvariable. Run the following command and copy the required AMI ID:$ aws ec2 describe-images --owners self$ AMI=<AMI_ID>Set the
SECURITY_GROUPvariable. Run the following command and copy the required security group ID:$ aws ec2 describe-security-groups$ SECURITY_GROUP=<SECURITY_GROUP_ID>Set the
SUBNETvariable. Run the following command and copy the required subnet:$ aws ec2 describe-subnets$ SUBNET=<SUBNET>Set the
INSTANCE_TYPEvariable:$ INSTANCE_TYPE=<INSTANCE_TYPE_SIZE>Set the
INSTANCE_NAMEvariable:$ INSTANCE_NAME=rhel-ai-instanceSet the disk size variable:
$ DISK_SIZE=<REQUIRED_DISK_SIZE>Set the
KEY_NAMEvariable:$ KEY_NAME=<KEY_PAIR_NAME>
Create the instance by running the following command:
$ aws ec2 run-instances \ --image-id $AMI \ --instance-type $INSTANCE_TYPE \ --key-name $KEY_NAME \ --security-group-ids $SECURITY_GROUP \ --subnet-id $SUBNET \ --block-device-mappings DeviceName=/dev/sda1,Ebs='{VolumeSize='$DISK_SIZE'}' \ --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value='$INSTANCE_NAME'}]'ImportantThe default user account in the RHEL AI AMI is
cloud-user. Thecloud-useraccount has passwordlesssudoaccess.