I want to create a RHEL OS EC2 Instance using AWS template. I don't have any RHEL instance currently. So don't have any Image-ID.
Red Hat maintains RHEL AMIs. We can use the CLI describe-images to query their public AMIs based on:
RHEL-*_HVM_GA-*-Hourly2-GP
For the sake of this example, we will sort the images by CreationDate, request only the last element in the collection (via -1) and filter the results down to Name, ImageId, and CreationDate.
Example:
aws ec2 describe-images \
--owners 309956199498 \
--filters "Name=name,Values=RHEL-*_HVM_GA-*-Hourly2-GP2" \
--query 'sort_by(Images, &CreationDate)[-1].[Name, ImageId, CreationDate]' \
--output text
Output:
RHEL-7.3_HVM_GA-20161026-x86_64-1-Hourly2-GP2 ami-b63769a1 2016-10-26T22:32:29.000Z
To verify this is correct, you can double-check by visiting the 'Quick Start' section of the AWS Console's EC2 'Launch Instances' Wizard and checking the most recent RHEL AMI that is sorted near the top of this quick start listing. At the time of this posting, the most recent RHEL AMI was ami-b63769a1
.
After this, you would take that resulting ImageId and use it as part of your request to launch a new instance.
Further Reading:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With