Created
April 29, 2021 02:09
-
-
Save hatchcanon/a90bae7d2c88ea55da7ec41ac1790cbc to your computer and use it in GitHub Desktop.
list all the AWS instances that are missing the SSM agent
This file contains 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
#!/bin/bash | |
for instance in $(aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --output text ) | |
do | |
managed=$(aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$instance" --query 'InstanceInformationList[*].[AssociationStatus]' --output text) | |
if [[ "$managed" != "Success" ]]; then | |
managed=" Not Managed"; | |
fi | |
aws ec2 describe-instances --instance-id $instance --output text --query 'Reservations[*].Instances[*].[InstanceId, Placement.AvailabilityZone, [Tags[?Key==`Name`].Value] [0][0], [Tags[?Key==`App`].Value] [0][0], [Tags[?Key==`Product`].Value] [0][0], [Tags[?Key==`Team`].Value] [0][0] ]' | |
echo " $managed" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment