Table: aws_ec2_ami_shared - Query AWS EC2 AMI using SQL
The AWS EC2 AMI (Amazon Machine Image) provides the information necessary to launch an instance, which is a virtual server in the cloud. You can specify an AMI when you launch instances, and you can launch as many instances from the AMI as you need. You can also share your own custom AMI with other AWS accounts, enabling them to launch instances with identical configurations.
Table Usage Guide
The aws_ec2_ami_shared
table in Steampipe provides you with information about shared Amazon Machine Images (AMIs) within AWS EC2. This table enables you, as a system administrator or DevOps engineer, to query shared AMI-specific details, including image ID, creation date, state, and associated tags. You can utilize this table to gather insights on shared AMIs, such as their availability, permissions, and associated metadata. The schema outlines the various attributes of the shared AMI, including the image type, launch permissions, and virtualization type.
Important Notes
- You must specify an Owner ID or Image ID in the
where
clause (where owner_id='
), (where image_id='
). - The
aws_ec2_ami_shared
table can list any image but you must specifyowner_id
orimage_id
. - If you want to list all of the images in your account then you can use the
aws_ec2_ami
table.
Examples
Basic info
Explore which AWS EC2 shared AMI resources are owned by a specific user to understand their configurations. This can be useful in auditing access and managing resources across your organization.
select name, image_id, state, image_location, creation_date, public, root_device_namefrom aws_ec2_ami_sharedwhere owner_id = '137112412989';
select name, image_id, state, image_location, creation_date, public, root_device_namefrom aws_ec2_ami_sharedwhere owner_id = '137112412989';
List arm64 AMIs
Explore which Amazon Machine Images (AMIs) with 'arm64' architecture are shared by a specific owner. This can be useful in identifying suitable AMIs for deployment on 'arm64' architecture instances.
select name, image_id, state, image_location, creation_date, public, root_device_namefrom aws_ec2_ami_sharedwhere owner_id = '137112412989' and architecture = 'arm64';
select name, image_id, state, image_location, creation_date, public, root_device_namefrom aws_ec2_ami_sharedwhere owner_id = '137112412989' and architecture = 'arm64';
List EC2 instances using AMIs owned by a specific AWS account
Explore which EC2 instances are using AMIs owned by a particular AWS account. This is useful to maintain account security and manage resources efficiently.
select i.title, i.instance_id, i.image_id, ami.name, ami.description, ami.platform_detailsfrom aws_ec2_instance as i join aws_ec2_ami_shared as ami on i.image_id = ami.image_idwhere ami.owner_id = '137112412989';
select i.title, i.instance_id, i.image_id, ami.name, ami.description, ami.platform_detailsfrom aws_ec2_instance as i join aws_ec2_ami_shared as ami on i.image_id = ami.image_idwhere ami.owner_id = '137112412989';
Schema for aws_ec2_ami_shared
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
architecture | text | = | The architecture of the image. |
block_device_mappings | jsonb | Any block device mapping entries. | |
boot_mode | text | The boot mode of the image. | |
creation_date | timestamp with time zone | The date and time when the image was created. | |
deprecation_time | timestamp with time zone | The date and time to deprecate the AMI. | |
description | text | = | The description of the AMI that was provided during image creation. |
ena_support | boolean | =, != | Specifies whether enhanced networking with ENA is enabled. |
hypervisor | text | = | The hypervisor type of the image. |
image_id | text | = | The ID of the AMI. |
image_location | text | The location of the AMI. | |
image_owner_alias | text | The AWS account alias (for example, amazon, self) or the AWS account ID of the AMI owner. | |
image_type | text | = | The type of image. |
imds_support | text | If v2.0, it indicates that IMDSv2 is specified in the AMI. | |
kernel_id | text | = | The kernel associated with the image, if any. Only applicable for machine images. |
name | text | = | The name of the AMI that was provided during image creation. |
owner_id | text | = | The AWS account ID of the image owner. |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
platform | text | = | This value is set to windows for Windows AMIs; otherwise, it is blank. |
platform_details | text | The platform details associated with the billing code of the AMI. For more information, see Obtaining Billing Information (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-billing-info.html) in the Amazon Elastic Compute Cloud User Guide. | |
product_codes | jsonb | Any product codes associated with the AMI. | |
public | boolean | =, != | Indicates whether the image has public launch permissions. The value is true if this image has public launch permissions or false if it has only implicit and explicit launch permissions. |
ramdisk_id | text | = | The RAM disk associated with the image, if any. Only applicable for machine images. |
region | text | The AWS Region in which the resource is located. | |
root_device_name | text | = | The device name of the root device volume (for example, /dev/sda1). |
root_device_type | text | = | The type of root device used by the AMI. The AMI can use an EBS volume or an instance store volume. |
source_instance_id | text | The ID of the instance that the AMI was created from if the AMI was created using CreateImage. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
sriov_net_support | text | = | Specifies whether enhanced networking with the Intel 82599 Virtual Function interface is enabled. |
state | text | = | The current state of the AMI. If the state is available, the image is successfully registered and can be used to launch an instance. |
state_reason | jsonb | The reason for the state change. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | A list of tags attached to the AMI. | |
title | text | Title of the resource. | |
tpm_support | text | If the image is configured for NitroTPM support, the value is v2.0. | |
usage_operation | text | The operation of the Amazon EC2 instance and the billing code that is associated with the AMI. For the list of UsageOperation codes, see Platform Details and [Usage Operation Billing Codes](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-billing-info.html#billing-info) in the Amazon Elastic Compute Cloud User Guide. | |
virtualization_type | text | = | The type of virtualization of the AMI. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws
You can pass the configuration to the command with the --config
argument:
steampipe_export_aws --config '<your_config>' aws_ec2_ami_shared