Este contenido no está disponible en el idioma seleccionado.
Chapter 15. Preparing and uploading AMI images to AWS
You can create custom images and update them, either manually or automatically, on the AWS cloud with RHEL image builder.
15.1. Preparing to manually upload AWS AMI images Copiar enlaceEnlace copiado en el portapapeles!
Before uploading an Amazon Web Services Machine image (AWS AMI) image, you must configure a system for uploading the images.
Prerequisites
- You must have an Access Key ID configured in the AWS IAM account manager.
- You must have a writable S3 bucket prepared.
Procedure
Install Python 3 and the
piptool:# dnf install python3 python3-pipInstall the AWS command-line tools with
pip:# pip3 install awscliSet your profile. The terminal prompts you to provide your credentials, region, and output format:
$ aws configure AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: Default output format [None]:Define a name for your bucket and create a bucket:
$ BUCKET=bucketname $ aws s3 mb s3://$BUCKETReplace
bucketnamewith the actual bucket name. It must be a globally unique name. As a result, your bucket is created.To grant Simple Storage Service (S3) access permission, create a
vmimportrole in the AWS Identity and Access Management (IAM), if you have not already.Create a
trust-policy.jsonfile with the trust policy configuration in JSON format. For example:{ "Version": "2022-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "Service": "vmie.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:Externalid": "vmimport" } } }] }Create a
role-policy.jsonfile with the role policy configuration, in the JSON format. For example:{ "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 $BUCKETCreate a role for your Amazon Web Services account, by using the
trust-policy.jsonfile:$ aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.jsonEmbed an inline policy document by using the
role-policy.jsonfile:$ aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json
15.2. Manually uploading an AMI image to AWS by using the CLI Copiar enlaceEnlace copiado en el portapapeles!
You can use RHEL image builder to build ami images and manually upload them directly to the Amazon AWS Cloud service provider by using the CLI.
Prerequisites
Procedure
Build the image:
# image-builder build ami \ --blueprint blueprint-name \ --aws-region us-east-1 \ --aws-bucket <example-bucket> \ --aws-ami-name <image-name> \Upload the image to AWS:
# image-builder upload <image-name> \
Verification
- Confirm the image upload by accessing EC2 in the AWS console and selecting the correct region.
- On the dashboard, select your image and click .
15.3. Creating and automatically uploading images to the AWS Cloud AMI Copiar enlaceEnlace copiado en el portapapeles!
You can create a .raw image by using RHEL image builder and select Upload to AWS to automatically push the image to the Amazon AWS Cloud AMI service provider.
Prerequisites
-
You must have
rootorwheelgroup user access to the system. - You have opened the RHEL image builder interface of the RHEL web console in a browser.
- You have created a blueprint. See Creating a blueprint in the web console interface.
- You must have an Access Key ID configured in the AWS IAM account manager.
- You must have a writable S3 bucket prepared.
Procedure
- In the RHEL image builder dashboard, select your blueprint in blueprint name. Select the Images tab, and click Create Image.
-
From the Type drop-down menu list, select
Amazon Machine Image Disk (.raw), check Upload to AWS, and click Next. Enter your
AWS access key IDandAWS secret access keyin the corresponding fields. Click Next.NoteIf you do not know your Secret Key, generate a new Access Key ID.
-
Enter the
Image name`,Amazon S3 bucketname, andAWS region, then click Next. - Review the information and click Finish. Wait for the Image build complete status.
-
In the AWS console, navigate to Service→EC2, select the correct region, and verify your image shows
Availablestatus. - Select your image, click Launch, choose an instance type, and click Review and Launch.
Review instance details, click Launch, then select or create a key pair:
- To create a new key pair, select Create a new key pair, enter a name, and click Download Key Pair.
- Click Launch Instance and wait the instance status to change to running.
Click Connect, then use SSH to access your instance:
$ chmod 400 <your_instance_name>.pem $ ssh -i <your-instance_name>.pem ec2-user@<your-instance-IP-address>-
Type
yesto confirm the connection.
-
Type
Verification
- Check if you are able to perform any action while connected to your instance by using SSH.