Last active
August 7, 2026 21:45
-
-
Save agoose77/d718716d6b9f11558e0083bba1359fb6 to your computer and use it in GitHub Desktop.
Find the AMI details for a deployed managed nodegroup on AWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| : "${nodegroup:?Need nodegroup}" | |
| : "${region:?Need region}" | |
| : "${cluster:?Need cluster}" | |
| # Get the autoscaling group name from the EKS node pool | |
| autoscaling_group_name=$(aws --region "${region}" eks describe-nodegroup --cluster-name "${cluster}" --nodegroup-name "${nodegroup}" --output json | jq '.nodegroup.resources.autoScalingGroups | last | .name' -r) | |
| # Determine the ASG launch template for this ASG | |
| launch_template_name=$(aws --region "${region}" autoscaling describe-auto-scaling-groups --auto-scaling-group-names "${autoscaling_group_name}" | jq '.AutoScalingGroups | last | .MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.LaunchTemplateName' -r ) | |
| # Now query the image ID for that template | |
| ami_id=$(aws --region "${region}" ec2 describe-launch-template-versions --launch-template-name "${launch_template_name}" --output json | jq '.LaunchTemplateVersions | last' | jq '.LaunchTemplateData.ImageId' -r) | |
| # Pull out the AMI version | |
| ami_name=$(aws --region "${region}" ec2 describe-images --image-ids "${ami_id}" | jq '.Images | last | .Name' -r) | |
| # Get the AMI tag | |
| ami_version=$(printf "${ami_name}" | grep -E "[^-]+$" -o) | |
| # Get the URL encoded link that finds that text | |
| ami_fragment=$(printf "${ami_name}" | jq -sRr @uri) | |
| # Display the URL to the release | |
| echo "https://github.com/awslabs/amazon-eks-ami/releases/tag/${ami_version}#:~:text=${ami_fragment}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment