0
0
AWScloud~10 mins

Instance metadata and user data in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to retrieve the instance ID from metadata.

AWS
curl http://169.254.169.254/latest/meta-data/[1]
Drag options to blanks, or click blank then click option'
Auser-data
Binstance-id
Cpublic-ipv4
Dsecurity-groups
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user-data' instead of 'instance-id' to get instance ID.
2fill in blank
medium

Complete the code to fetch the user data of an EC2 instance.

AWS
curl http://169.254.169.254/latest/[1]
Drag options to blanks, or click blank then click option'
Auser-data
Bhostname
Cami-id
Dinstance-id
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'instance-id' instead of 'user-data' to get user data.
3fill in blank
hard

Fix the error in the command to get the public IPv4 address from metadata.

AWS
curl http://169.254.169.254/latest/meta-data/[1]
Drag options to blanks, or click blank then click option'
Apublic-ipv6
Blocal-ipv4
Cprivate-ipv4
Dpublic-ipv4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local-ipv4' or 'private-ipv4' which give internal IPs.
4fill in blank
hard

Fill both blanks to retrieve the security groups and the AMI ID from metadata.

AWS
curl http://169.254.169.254/latest/meta-data/[1] && curl http://169.254.169.254/latest/meta-data/[2]
Drag options to blanks, or click blank then click option'
Asecurity-groups
Binstance-type
Cami-id
Dpublic-hostname
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing 'instance-type' or 'public-hostname' instead of 'ami-id'.
5fill in blank
hard

Fill all three blanks to write a shell script that fetches instance ID, user data, and availability zone.

AWS
#!/bin/bash
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/[1])
USER_DATA=$(curl http://169.254.169.254/latest/[2])
AZ=$(curl http://169.254.169.254/latest/meta-data/[3])
echo "Instance ID: $INSTANCE_ID"
echo "User Data: $USER_DATA"
echo "Availability Zone: $AZ"
Drag options to blanks, or click blank then click option'
Ainstance-id
Buser-data
Cplacement/availability-zone
Dpublic-ipv4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'public-ipv4' instead of availability zone path.