-
-
Save jaymecd/ef6635dd131181d67613427d96824025 to your computer and use it in GitHub Desktop.
Cloud-init directive to add AWS SSM checking at boot time
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
#cloud-config | |
write_files: | |
- content: | | |
#!/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 | |
path: /var/lib/cloud/scripts/per-boot/ssmcheck.sh | |
owner: root:root | |
permissions: '0755' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment