Identify your resources referencing specified AMIs
You can identify your AWS resources that reference specified Amazon Machine Images (AMIs), regardless of whether the AMIs are public or private, or who owns them. This visibility helps you ensure your resources use the latest compliant AMIs.
Key benefits
Checking AMI references helps you:
-
Audit the use of AMIs in your account.
-
Check where specific AMIs are being referenced.
-
Maintain compliance by updating your resources to reference the latest AMIs.
Topics
Supported resources
AMI references can be checked in:
-
EC2 instances
-
Launch templates
-
SSM parameters
-
Image Builder image recipes
-
Image Builder container recipes
How AMI reference checks work
Basic operation
When you run an AMI reference check, you:
-
Specify which AMIs to check.
-
Choose which resource types to scan.
-
Receive a list of your resources that reference the specified AMIs.
Resource type selection
In the console, you select the resource types to scan.
In the CLI, you specify resource types to scan using one or both of the following CLI parameters:
-
IncludeAllResourceTypes
: Scans all supported resource types. -
ResourceTypes
: Scans your specified resource types.
Response scoping
You can scope the response for EC2 instances and launch templates by customizing the
ResourceTypeOptions
values using the ResourceTypes
parameter. The console and IncludeAllResourceTypes
parameter both use
default option values. When ResourceTypes
and
IncludeAllResourceTypes
are used together, the
ResourceTypes
option values take precedence over the defaults.
The following are the default values:
Resource type | Scoping option (OptionName ) |
Purpose | Default values for OptionValue and console |
---|---|---|---|
EC2 instances | state-name |
Filter by instance state | pending , running ,
shutting-down , terminated ,
stopping , stopped (all states) |
Launch templates | version-depth |
Specify the number of launch template versions to check (starting from the most recent version) | 10 (most recent versions) |
Required IAM permissions
To use the DescribeImageReferences API to identify your resources that are referencing specified AMIs, you need the following IAM permissions:
-
ec2:DescribeInstances
– To describe EC2 instances -
ec2:DescribeLaunchTemplates
– To describe launch templates -
ec2:DescribeLaunchTemplateVersions
– To describe launch template versions -
ssm:DescribeParameters
– To describe Systems Manager parameters -
ssm:GetParameters
– To get information about Systems Manager parameters -
imagebuilder:ListImageRecipes
– To describe Image Builder image recipes -
imagebuilder:ListContainerRecipes
– To describe Image Builder container recipes -
imagebuilder:GetContainerRecipe
– To retrieve Image Builder container recipes
Example IAM policy for using the DescribeImageReferences API
The following example policy grants you the permissions to use the DescribeImageReferences API, which includes the permissions to describe EC2 instances, launch templates, Systems Manager parameters, Image Builder image recipes, and Image Builder container recipes.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "ec2:DescribeImageReferences", "Resource": "*" }, { "Effect": "Allow", "Action": [ "ec2:DescribeInstances", "ec2:DescribeLaunchTemplates", "ec2:DescribeLaunchTemplateVersions", "ssm:DescribeParameters", "ssm:GetParameters", "imagebuilder:ListImageRecipes", "imagebuilder:ListContainerRecipes", "imagebuilder:GetContainerRecipe" ], "Resource": "*", "Condition": { "ForAnyValue:StringEquals": { "aws:CalledVia": [ "ec2-images.amazonaws.com" ] } } } ] }
Important
When granting permissions to users, groups, and roles, we strongly recommend using the
AmazonEC2ImageReferencesAccessPolicy
AWS
managed policy instead of creating the policy yourself. This is especially important
when using the IncludeAllResourceTypes
parameter, as the managed policy
will automatically include permissions for new resource types as they become available.
Creating a custom IAM policy that provides your team with only the the permissions they
need requires time and expertise.
The AmazonEC2ImageReferencesAccessPolicy
managed policy grants
the permissions needed to use the DescribeImageReferences API, which
include the permissions to view EC2 instances, launch templates, Systems Manager
parameters, Image Builder container recipes, and Image Builder image recipes. The policy
supports the IncludeAllResourceTypes
parameter and will continue to work
when AWS adds support for new resource types without your needing to do
anything.
You can attach the AmazonEC2ImageReferencesAccessPolicy
policy
to your IAM identities.
To view the permissions for this policy, see AmazonEC2ImageReferencesAccessPolicy in the AWS Managed Policy Reference.
Steps for checking AMI references
Use the following procedures to identify which of your AWS resources are referencing specified AMIs.