Retrieve macOS AMI IDs using AWS Systems Manager Parameter Store API - Amazon Elastic Compute Cloud

Retrieve macOS AMI IDs using AWS Systems Manager Parameter Store API

You can view all of the macOS AMIs in an AWS Region and retrieve the latest macOS AMI by querying the AWS Systems Manager Parameter Store API. Using these public parameters, you don't need to manually look up macOS AMI IDs. Public parameters are available for both x86 and ARM64 macOS AMIs and can be integrated with existing AWS CloudFormation templates.

Permissions

The IAM principal that you use must have the ssm:GetParameter IAM permission.

To view a list of all macOS AMIs in the current AWS Region using the AWS CLI

Use the following get-parameters-by-path command to view a list of all macOS AMIs in the current Region.

aws ssm get-parameters-by-path -—path /aws/service/ec2-macos -—query "Parameters[].Name"
To retrieve the AMI ID of the latest major macOS AMI using the AWS CLI

Use the following get-parameter command with the sub-parameter image_id. In the following example, replace sonoma with a macOS supported major version, x86_64_mac with the processor, and region-code with a supported AWS Region for which you want the latest macOS AMI ID.

aws ssm get-parameter --name /aws/service/ec2-macos/sonoma/x86_64_mac/latest/image_id --region region-code

For more information, see Calling AMI public parameters for macOS in the AWS Systems Manager User Guide.