官术网_书友最值得收藏!

Amazon Machine Images (AMIs)

An AMI is a package that contains, among other things, the root file system with the operating system (for example, Linux, UNIX, or Windows) as well as additional software required to start up the system. To find the proper AMI, we will use the aws ec2 describe-images command. By default, the describe-images command will list all available public AMIs, which is way over 3 million by now. To get the best out of that command, it is important to combine it with the filter option to only include the AMI we would like to use. In our case, we want to use the following to filter our AMIs:

  • We want the name to be Amazon Linux AMI, which designates the Linux distribution officially supported by AWS. Amazon Linux is based off Red Hat/CentOS but includes a few extra packages to make the integration with other AWS services easy to do. You can read more about AWS Linux at http://amzn.to/2uFT13F.
  • We want to use the x84_64 bits version of Linux to match the architecture we will use.
  • The virtualization type should be HVM, which stands for hardware virtual machine. This is the newest and best-performing type of virtualization.
  • We want GP2 support, which will let us use the newest generation of instances that don't come with instance store, meaning that the servers that power our instances will be different from the servers that store our data.

In addition, we will sort the output by age and only look at the most recently released AMI:

$ aws ec2 describe-images --filters "Name=description,Values=Amazon Linux AMI * x86_64 HVM GP2" --query 'Images[*].[CreationDate, Description, ImageId]' --output text | sort -k 1 | tail

The output of running the preceding command can be shown as follows:

As you can see, at this time, the most recent AMI ID is ami-cfe4b2b0. This might differ by the time you execute the same command, as the Amazon vendors included regularly update their OS.

When using the aws cli --query option, the output can be very consequential for certain commands. Taking the preceding example, if we only care about a subset of information, we can supplement the commands with the  --query option to filter the information we want only . This option uses the JMESPath query language.
主站蜘蛛池模板: 蒙自县| 荆州市| 酉阳| 昆山市| 洪泽县| 呼和浩特市| 扶沟县| 沙洋县| 鄱阳县| 东宁县| 旬阳县| 湾仔区| 瑞丽市| 屏东市| 永兴县| 霍林郭勒市| 高阳县| 吕梁市| 北川| 柘荣县| 叶城县| 广德县| 板桥市| 都安| 尼玛县| 仪征市| 清远市| 锦屏县| 平塘县| 图木舒克市| 方城县| 马龙县| 朝阳区| 庐江县| 贵阳市| 深泽县| 漯河市| 永丰县| 扶余县| 宜黄县| 荔波县|