steampipe plugin install aws

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 specify owner_id or image_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_name
from
aws_ec2_ami_shared
where
owner_id = '137112412989';
select
name,
image_id,
state,
image_location,
creation_date,
public,
root_device_name
from
aws_ec2_ami_shared
where
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_name
from
aws_ec2_ami_shared
where
owner_id = '137112412989'
and architecture = 'arm64';
select
name,
image_id,
state,
image_location,
creation_date,
public,
root_device_name
from
aws_ec2_ami_shared
where
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_details
from
aws_ec2_instance as i
join aws_ec2_ami_shared as ami on i.image_id = ami.image_id
where
ami.owner_id = '137112412989';
select
i.title,
i.instance_id,
i.image_id,
ami.name,
ami.description,
ami.platform_details
from
aws_ec2_instance as i
join aws_ec2_ami_shared as ami on i.image_id = ami.image_id
where
ami.owner_id = '137112412989';

Schema for aws_ec2_ami_shared

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The AWS Account ID in which the resource is located.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
architecturetext=The architecture of the image.
block_device_mappingsjsonbAny block device mapping entries.
creation_datetimestamp with time zoneThe date and time when the image was created.
descriptiontext=The description of the AMI that was provided during image creation.
ena_supportboolean=, !=Specifies whether enhanced networking with ENA is enabled.
hypervisortext=The hypervisor type of the image.
image_idtext=The ID of the AMI.
image_locationtextThe location of the AMI.
image_owner_aliastextThe AWS account alias (for example, amazon, self) or the AWS account ID of the AMI owner.
image_typetext=The type of image.
imds_supporttextIf v2.0, it indicates that IMDSv2 is specified in the AMI.
kernel_idtext=The kernel associated with the image, if any. Only applicable for machine images.
nametext=The name of the AMI that was provided during image creation.
owner_idtext=The AWS account ID of the image owner.
partitiontextThe AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).
platformtext=This value is set to windows for Windows AMIs; otherwise, it is blank.
platform_detailstextThe 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_codesjsonbAny product codes associated with the AMI.
publicboolean=, !=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_idtext=The RAM disk associated with the image, if any. Only applicable for machine images.
regiontextThe AWS Region in which the resource is located.
root_device_nametext=The device name of the root device volume (for example, /dev/sda1).
root_device_typetext=The type of root device used by the AMI. The AMI can use an EBS volume or an instance store volume.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
sriov_net_supporttext=Specifies whether enhanced networking with the Intel 82599 Virtual Function interface is enabled.
statetext=The current state of the AMI. If the state is available, the image is successfully registered and can be used to launch an instance.
tagsjsonbA map of tags for the resource.
tags_srcjsonbA list of tags attached to the AMI.
titletextTitle of the resource.
usage_operationtextThe 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_typetext=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