Skip to main content

image_usage_reports

Creates, updates, deletes, gets or lists an image_usage_reports resource.

Overview

Nameimage_usage_reports
TypeResource
Idaws.ec2.image_usage_reports

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
account_idsstringThe IDs of the Amazon Web Services accounts that were specified when the report was created.
creation_timestringThe date and time when the report was created.
expiration_timestringThe date and time when Amazon EC2 will delete the report (30 days after the report was created).
image_idstringThe ID of the image that was specified when the report was created.
report_idstringThe ID of the report.
resource_typesstringThe resource types that were specified when the report was created.
statestringThe current state of the report. Possible values: available - The report is available to view. pending - The report is being created and not available to view. error - The report could not be created.
state_reasonstringProvides additional details when the report is in an error state.
tagsstringAny tags assigned to the report.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_image_usage_reportsselectregionImageId, ReportId, NextToken, Filter, DryRun, MaxResultsDescribes the configuration and status of image usage reports, filtered by report IDs or image IDs. For more information, see View your AMI usage in the Amazon EC2 User Guide.
create_image_usage_reportinsertImageId, ResourceType, regionDryRun, AccountId, ClientToken, TagSpecificationCreates a report that shows how your image is used across other Amazon Web Services accounts. The report provides visibility into which accounts are using the specified image, and how many resources (EC2 instances or launch templates) are referencing it. For more information, see View your AMI usage in the Amazon EC2 User Guide.
delete_image_usage_reportdeleteReportId, regionDryRunDeletes the specified image usage report. For more information, see View your AMI usage in the Amazon EC2 User Guide.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
ImageIdstringThe ID of the image to report on.
ReportIdstringThe ID of the report to delete.
ResourceTypearrayThe resource types to include in the report.
regionstringAWS region (default: us-east-1)
AccountIdarrayThe Amazon Web Services account IDs to include in the report. To include all accounts, omit this parameter.
ClientTokenstringA unique, case-sensitive identifier that you provide to ensure idempotency of the request.
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
FilterarrayThe filters. creation-time - The time when the report was created, in the ISO 8601 format in the UTC time zone (YYYY-MM-DDThh:mm:ss.sssZ), for example, 2025-11-29T11:04:43.305Z. You can use a wildcard (), for example, 2025-11-29T, which matches an entire day. state - The state of the report (available | pending | error). tag:<key> - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value. tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.
ImageIdarrayThe IDs of the images for filtering the reports. If specified, only reports containing these images are returned.
MaxResultsintegerThe maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.
NextTokenstringThe token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.
ReportIdarrayThe IDs of the image usage reports.
TagSpecificationarrayThe tags to apply to the report on creation. The ResourceType must be set to image-usage-report; any other value will cause the report creation to fail. To tag a report after it has been created, see CreateTags.

SELECT examples

Describes the configuration and status of image usage reports, filtered by report IDs or image IDs. For more information, see View your AMI usage in the Amazon EC2 User Guide.

SELECT
account_ids,
creation_time,
expiration_time,
image_id,
report_id,
resource_types,
state,
state_reason,
tags
FROM aws.ec2.image_usage_reports
WHERE region = '{{ region }}' -- required
AND ImageId = '{{ ImageId }}'
AND ReportId = '{{ ReportId }}'
AND NextToken = '{{ NextToken }}'
AND Filter = '{{ Filter }}'
AND DryRun = '{{ DryRun }}'
AND MaxResults = '{{ MaxResults }}'
;

INSERT examples

Creates a report that shows how your image is used across other Amazon Web Services accounts. The report provides visibility into which accounts are using the specified image, and how many resources (EC2 instances or launch templates) are referencing it. For more information, see View your AMI usage in the Amazon EC2 User Guide.

INSERT INTO aws.ec2.image_usage_reports (
ImageId,
ResourceType,
region,
DryRun,
AccountId,
ClientToken,
TagSpecification
)
SELECT
'{{ ImageId }}',
'{{ ResourceType }}',
'{{ region }}',
'{{ DryRun }}',
'{{ AccountId }}',
'{{ ClientToken }}',
'{{ TagSpecification }}'
RETURNING
report_id
;

DELETE examples

Deletes the specified image usage report. For more information, see View your AMI usage in the Amazon EC2 User Guide.

DELETE FROM aws.ec2.image_usage_reports
WHERE ReportId = '{{ ReportId }}' --required
AND region = '{{ region }}' --required
AND DryRun = '{{ DryRun }}'
;