Bird
0
0

Given this user data script:

medium📝 Predict Output Q4 of 15
AWS - EC2 Fundamentals
Given this user data script:
#!/bin/bash
echo "Instance ID: $(curl -s http://169.254.169.254/latest/meta-data/instance-id)" > /tmp/instance.txt

What will be the content of /tmp/instance.txt after instance launch?
AInstance ID: http://169.254.169.254/latest/meta-data/instance-id
BInstance ID: curl command
CInstance ID: i-1234567890abcdef0
DInstance ID: $(curl -s http://169.254.169.254/latest/meta-data/instance-id)
Step-by-Step Solution
Solution:
  1. Step 1: Understand command substitution in bash

    The $(curl ...) runs the curl command and inserts its output into the string.
  2. Step 2: Recognize metadata instance-id output

    The curl command fetches the actual instance ID like i-1234567890abcdef0.
  3. Final Answer:

    Instance ID: i-1234567890abcdef0 -> Option C
  4. Quick Check:

    $(curl ...) inserts metadata value [OK]
Quick Trick: $(curl ...) runs command and inserts output in bash [OK]
Common Mistakes:
  • Thinking the command itself is written literally
  • Confusing URL string with command output
  • Not understanding command substitution

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes