Reference the latest AMIs using Systems Manager public parameters - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Reference the latest AMIs using Systems Manager public parameters

Amazon Systems Manager provides public parameters for public AMIs maintained by Amazon. You can use the public parameters when launching instances to ensure that you're using the latest AMIs. For example, the public parameter /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64 is available in all Regions and always points to the latest version of the Amazon Linux 2023 AMI for arm64 architecture in a given Region.

The public parameters are available from the following paths:

  • Linux/aws/service/ami-amazon-linux-latest

  • Windows/aws/service/ami-windows-latest

For more information, see Working with public parameters in the Amazon Systems Manager User Guide.

List the Amazon Linux AMIs

Amazon CLI
To list the Linux AMIs in the current Amazon Region

Use the following get-parameters-by-path command. The value for the --path parameter is specific to Linux AMIs.

aws ssm get-parameters-by-path \ --path /aws/service/ami-amazon-linux-latest \ --query "Parameters[].Name"
PowerShell
To list the Linux AMIs in the current Amazon Region

Use the Get-SSMParametersByPath cmdlet.

Get-SSMParametersByPath ` -Path "/aws/service/ami-amazon-linux-latest" | ` Sort-Object Name | Format-Table Name

List the Windows AMIs

Amazon CLI
To list the Windows AMIs in the current Amazon Region

Use the following get-parameters-by-path command. The value for the --path parameter is specific to Windows AMIs.

aws ssm get-parameters-by-path \ --path /aws/service/ami-windows-latest \ --query "Parameters[].Name"
PowerShell
To list the Windows AMIs in the current Amazon Region

Use the Get-SSMParametersByPath cmdlet.

Get-SSMParametersByPath ` -Path "/aws/service/ami-windows-latest" | ` Sort-Object Name | Format-Table Name

Launch an instance using a public parameter

To specify the public parameter when launching an instance, use the following syntax: resolve:ssm:public-parameter, where resolve:ssm is the standard prefix and public-parameter is the path and name of the public parameter.

Amazon CLI
To launch an instance using a public parameter

Use the run-instances command with the --image-id option. This example specifies a Systems Manager public parameter for the image ID to launch an instance using the latest Amazon Linux 2023 AMI

--image-id resolve:ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64
PowerShell
To launch an instance using a public parameter

Use the New-EC2Instance cmdlet with the -ImageId parameter. This example specifies a Systems Manager public parameter for the image ID to launch an instance using the latest AMI for Windows Server 2022.

-ImageId "resolve:ssm:/aws/service/ami-windows-latest/Windows_Server-2022-English-Full-Base"

For more examples that use Systems Manager parameters, see Query for the latest Amazon Linux AMI IDs Using Amazon Systems Manager Parameter Store and Query for the Latest Windows AMI Using Amazon Systems Manager Parameter Store.