Bird
0
0

Which of the following is the correct syntax to include a user data script in an EC2 launch configuration?

easy📝 Syntax Q3 of 15
AWS - EC2 Fundamentals
Which of the following is the correct syntax to include a user data script in an EC2 launch configuration?
AUserData: "instance metadata access script"
BUserData: "curl http://169.254.169.254/latest/meta-data/"
CUserData: "#!/bin/bash\necho Hello World > /home/ec2-user/hello.txt"
DUserData: "aws ec2 describe-instances"
Step-by-Step Solution
Solution:
  1. Step 1: Identify user data script format

    User data scripts start with a shebang like #!/bin/bash and contain shell commands.
  2. Step 2: Check the example commands

    Only UserData: "#!/bin/bash\necho Hello World > /home/ec2-user/hello.txt" shows a valid bash script writing to a file.
  3. Final Answer:

    UserData: "#!/bin/bash\necho Hello World > /home/ec2-user/hello.txt" -> Option C
  4. Quick Check:

    User data = bash script with #!/bin/bash [OK]
Quick Trick: User data scripts start with #!/bin/bash for Linux instances [OK]
Common Mistakes:
MISTAKES
  • Putting metadata commands in user data
  • Using AWS CLI commands directly in user data without context
  • Writing plain text instead of script

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes