Created
November 27, 2023 12:23
-
-
Save phainamikaze/05c492a68f9dc5267a8909e9124fd237 to your computer and use it in GitHub Desktop.
EC2 Instance Connect session lab 171
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
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` | |
#Set the Region | |
AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone -H "X-aws-ec2-metadata-token: $TOKEN"` | |
export AWS_DEFAULT_REGION=${AZ::-1} | |
echo $AWS_DEFAULT_REGION | |
#Retrieve latest Linux AMI | |
AMI=$(aws ssm get-parameters --names /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 --query 'Parameters[0].[Value]' --output text) | |
echo $AMI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment