Last active
October 14, 2017 17:17
-
-
Save ktstevenson/c3f2a2178e1fe33724b1e7cc64e7b64b to your computer and use it in GitHub Desktop.
Stop Amazon SSM agent if instance lacks basic SSM permissions
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 | |
REGION=$( curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | python -c "import sys, json; print json.load(sys.stdin)['region']" ) | |
aws --region $REGION ssm list-associations --max-items 1 > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "No privs to run Amazon SSM agent. Stopping..." | |
sudo stop amazon-ssm-agent | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment