amazon machine image Is a template that is used to launch EC2 instances. An AMI is similar to a blueprint that contains an operating system and all required software, or application configuration for the instance. AMIs can be pre-built or custom-managed. AWS CLI is a powerful utility to access and manage images through simple commands like “descriptive picture” Permission. “descriptive picture” The command is used to list all configured AMIs for a given account.
quick outline
In this article we will learn about:
What is the “describe-images” command in AWS CLI?
“descriptive picture” The command in the AWS CLI is a paged operation that is used to list all or specific AMIs within an account. output of “descriptive picture” The command is in list form which contains information about various images. These images can be public, private, user-defined, or AWS-managed. When pagination is enabled the AMI's data is accessed across multiple API calls to the service.
Read more: How to Disable Pages in AWS CLI?
How to use “describe-images” command in AWS CLI?
Deregistered images are those that have been removed from AWS and are no longer supported by the EC2 service and platform. However, these images are also included in its output “descriptive picture” Permission. The user can control the output of the command by filtering, querying or specifying a particular AMI etc. through many different parameters.
syntax
syntax of “descriptive picture” The order is given as follows:
AWS EC2 Description-Images <Option,
Option
Here is a brief description of the options in the above command:
Option | Description |
-executable-user | This parameter is used to extract and list AMIs based on the user's permissions. The user can specify either “self”, “everyone”, or an AWS account ID. |
-Filter | -Filter parameter is used to list specific details or AMIs in the output. The different filter types supported by this command are:
, Name: User can filter AMIs by specifying name. , Owner-ID: AWS Account ID can filter AMIs by describing only images that are configured in a specific account. , tag: Tags are combinations of key-value pairs. By specifying tags, the user can easily filter AMIs for a given account. , Image-ID: Another way to filter AMIs is to specify the image ID. This will only list a specific AMI. |
-image-id | This parameter inputs the ID of the AMI. |
-Owner | The -owner parameter accepts the account ID, own, amazon, or aws-marketplace options. These options will list only those AMIs that exactly match the specified option. |
-Include-Exclude | This parameter is used to specify whether to list obsolete AMIs. Obsolete AMIs are images that are no longer recommended for use. |
-include-disable | This field specifies whether disabled AMIs should be listed in the output. |
-Rehearsal | The -dry-run parameter is used to determine whether the user has permission to perform the desired action. It returns the output in error format. Also, if the user has permissions, the output will include “DryRunOperation”. If the user is not equipped with this permission, it will return “UnauthorizedOperation” in the output. |
-cli-input-json | This parameter is used to provide multiple JSON directives together as templates for AWS services. The template followed is generated by the “-generate-cli-skeleton” parameter. |
-initial-token | This parameter inputs the value of the “NextToken” field from the output. The NextToken symbolizes that there is more data to list. When the value of nextToken is provided to -starting-token, it will start listing data from the previous response. |
-page size | This parameter defines the page size in each service AWS service call. Smaller page size results in more API calls which prevent a timeout error. However, it retrieves less data in each call. |
-max-items | The -max-items parameter is used to limit the number of entries displayed in the output. |
-generate-cli-skeleton | It creates a framework or template that must be followed when providing multiple instructions to an AWS service. |
Apart from these options, there are also global options provided by AWS. Global options are common to AWS CLI commands and can be used with different commands. AWS Documentation Discusses various global options.
Example
This section of the article discusses various examples “descriptive picture” Commands in AWS CLI:
Example 1: How to describe images in AWS CLI?
“descriptive picture” The command in the AWS CLI is used to list details of specific AMIs for a given account. This command requires the AMI's Image ID. Go to EC2 service and click “ami” Options from the left navigation pane. Select Create Image and it will display the configuration of the image. inside Description Section, copy and save the AMI ID:
The order in which specific AMIs are listed is as follows:
AWS EC2 Description-Images –Area AP-Southeast-1 –image-id <AMIImageID,
Comment: replace the
Production
Example 2: How to describe all images in AWS CLI?
The command to list all images available in the AWS CLI is as follows:
Production
It will take some time to display the list of all images. keep pressing “enter” Key from keyboard to see details of all images:
Example 3: How to describe AMI by owner ID in AWS CLI?
AMIs configured within an AWS account can also be determined by owner or account ID. The account ID can be determined by clicking the username in the upper-right corner of the AWS Management Console. Click “copy” Icon to copy account ID:
The command is customized with an additional parameter in the following way:
AWS EC2 Description-Images –Owner <Account ID,
Comment: replace the <खाताआईडी> With your AWS account ID.
Production
Example 4: How to filter images in AWS CLI?
Different filters are available to extract specific image details. User can filter images based on owner id, image id, tags, name or status etc. To list an image by its name, the following command is used:
AWS EC2 Description-Images –filter “name=name, value=ec2image”
Comment: replace the “ec2image” with the name of your AMI in the value.
Production
The value of the key-value pair of an AMI's tag can be determined by selecting the AMI from the AMI dashboard. This will display the configuration of the image. pat down “tag” Tab and copy the value of the key-value field:
To filter an image by its tag, the command is given below:
AWS EC2 Description-Images –filter “name=tag:firstkey, value=first”
Comment: replace the “First Key” In the Name field with the key. Similarly, replace “First” In the value with the value of the tag.
Production
Example 5: How to query AMI in AWS CLI?
User can extract specific details of an image from the displayed list using “-Question” Parameters. The order is given as follows:
AWS EC2 Description-Images –Question “Images[*],[ImageId],
Production
Similarly, the user can also query specific details of an image by specifying the image ID with the query parameter:
AWS EC2 Description-Images –image-id <AMII, –Question “image[*],[ImageType, Description, State],
Production
Example 6: How to describe rejected images in AWS CLI?
Deprecated AMIs are images that are no longer recommended for use by AWS. To determine which images are obsolete, use the following command:
AWS EC2 Description-Images –include-exclude
Production
Similarly, the user can also specify “-not-include-exclude” Parameters to list all images including obsolete images:
AWS EC2 Description-Images –not-include-exclude
Production
Example 7: How to describe enabled or disabled images in AWS CLI?
“descriptive picture” The command can also be used to list images that are disabled or not disabled for an account. This will help users determine which AMI to use. The command below is used to list the AMIs that are disabled for an account:
AWS EC2 Description-Images –include-disable
Production
Similarly, “descriptive picture” The command returns only those AMIs that are not disabled for a given account. For this purpose, use the command below:
AWS EC2 Description-Images –no-include-disable
Production
Example 8: How to describe images in multiple output formats?
There are many output formats supported by “descriptive picture” Permission. Formats include YAML, JSON, text, or table. The command to describe images in tabular format is given below:
AWS EC2 Description-Images –Output table
Comment: replace the “table” Values in output fields with a different output format of your choice, such as JSON, YAML, or text.
Production
Press “enter” To continue listing data from the keyboard:
conclusion
“descriptive picture” The command in AWS returns a list of all or specific AMIs for a given account. It accepts optional parameters like -query, -output, etc. “descriptive picture” The command is helpful for AWS developers as it helps them understand the different AMIs for their applications and decide between them. before using “descriptive picture” command, ensure that AWS CLI is configured on your local machines, and then provide the mentioned command to the terminal. This article provides a deeper understanding of “descriptive picture” Command with several examples to discuss its various parameters.