Skip to content

Instantly share code, notes, and snippets.

@MichaelScovell
Created April 19, 2021 12:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelScovell/a5a75c362058fdb0c61cbb0cfc3a9a63 to your computer and use it in GitHub Desktop.
Save MichaelScovell/a5a75c362058fdb0c61cbb0cfc3a9a63 to your computer and use it in GitHub Desktop.
disable-ec2-imds.sh
#!/bin/bash
# Script that will disable the metadata for the given instance.
#Create variable for instance ID
instanceID=$1
#Check to ensure that the instance is not blank
if [[ -n $instanceID ]];
then
#Remove EC2 IMDS
aws ec2 modify-instance-metadata-options \
--instance-id ${instanceID} \
--http-endpoint disabled
else
#Return this message and exit the script
echo "The instanceID is blank. Please try passing in the ID when running the script"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment