0
0
AWScloud~20 mins

Instance metadata and user data in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Instance Metadata Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What data can an EC2 instance retrieve from its metadata service?

An EC2 instance can query its instance metadata service to get information about itself. Which of the following types of data can it retrieve?

AThe instance's public IP address, instance ID, and security groups attached
BThe contents of all S3 buckets in the AWS account
CThe private keys of the AWS account root user
DThe billing details of the AWS account
Attempts:
2 left
💡 Hint

Think about what information is specific to the instance itself and what would be sensitive or unrelated.

Configuration
intermediate
2:00remaining
What is the correct way to pass user data to an EC2 instance during launch?

You want to run a script automatically when your EC2 instance starts. How should you provide this script using user data?

AAttach the script as a file to the instance's EBS volume after launch
BInclude the script as plain text in the user data field when launching the instance
CUpload the script to an S3 bucket and provide the S3 URL in user data
DSend the script via SSH after the instance is running
Attempts:
2 left
💡 Hint

User data is designed to run commands or scripts at instance boot time.

security
advanced
2:00remaining
What security risk is associated with instance metadata service (IMDS) version 1?

IMDSv1 allows EC2 instances to access metadata via HTTP requests. What is a known security risk of using IMDSv1 compared to IMDSv2?

AIMDSv1 is vulnerable to SSRF attacks that can expose sensitive metadata
BIMDSv1 encrypts metadata with weak algorithms
CIMDSv1 disables instance role permissions by default
DIMDSv1 requires manual credential rotation
Attempts:
2 left
💡 Hint

Consider how metadata is accessed and what an attacker might exploit.

Architecture
advanced
2:00remaining
How can you securely provide secrets to an EC2 instance without exposing them in user data?

You want your EC2 instance to access database credentials securely without embedding them in user data. Which approach is best?

AHardcode the credentials in the instance AMI
BStore the credentials in user data encrypted with base64
CAssign an IAM role to the instance with permissions to access AWS Secrets Manager
DSend the credentials via email to the instance owner
Attempts:
2 left
💡 Hint

Think about AWS services designed for secret management and secure access.

Best Practice
expert
2:00remaining
What is the recommended way to enforce use of IMDSv2 on EC2 instances to improve security?

You want to ensure all EC2 instances in your environment use IMDSv2 only, disabling IMDSv1. How can you enforce this?

ADisable the EC2 instance's network interface
BBlock all HTTP traffic to 169.254.169.254 from the instance
CRemove the instance profile attached to the instance
DConfigure the instance metadata options to require IMDSv2 and disable IMDSv1 during instance launch or via API
Attempts:
2 left
💡 Hint

Look for instance metadata options that control IMDS versions.