Reference the latest AMIs using Systems Manager public parameters - Amazon Elastic Compute Cloud

Reference the latest AMIs using Systems Manager public parameters

AWS Systems Manager provides public parameters for public AMIs maintained by AWS. 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

To view a list of all the Linux or Windows AMIs in the current AWS Region

Use the following get-parameters-by-path command to view a list of all the Linux or Windows AMIs in the current AWS Region. The value for the --path parameter is different for Linux and Windows.

For Linux:

aws ssm get-parameters-by-path \ --path /aws/service/ami-amazon-linux-latest \ --query "Parameters[].Name"

For Windows:

aws ssm get-parameters-by-path \ --path /aws/service/ami-windows-latest \ --query "Parameters[].Name"
To launch an instance using a public parameter

The following example specifies a Systems Manager public parameter for the image ID to launch an instance using the latest Amazon Linux 2023 AMI.

To specify the parameter in the command, 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.

In this example, the --count and --security-group parameters are not included. For --count, the default is 1. If you have a default VPC and a default security group, they are used.

aws ec2 run-instances \ --image-id resolve:ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 \ --instance-type m5.xlarge \ --key-name MyKeyPair

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

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