Challenge - 5 Problems
AMI Lookup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding AMI Lookup Data Source Behavior
What does the following Terraform data source configuration do?
data "aws_ami" "example" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-gp2"]
}
}Terraform
data "aws_ami" "example" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["amzn2-ami-hvm-*-x86_64-gp2"] } }
Attempts:
2 left
💡 Hint
Look at the 'data' block and the 'most_recent' attribute.
✗ Incorrect
The 'aws_ami' data source fetches information about an existing AMI. Setting 'most_recent = true' and filtering by name and owner returns the latest matching AMI owned by Amazon.
❓ Configuration
intermediate2:00remaining
Identify the Correct AMI ID Output
Given this Terraform configuration, what will be the value of
output.ami_id?data "aws_ami" "example" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-2.0.*-x86_64-gp2"]
}
}
output "ami_id" {
value = data.aws_ami.example.id
}Terraform
data "aws_ami" "example" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["amzn2-ami-hvm-2.0.*-x86_64-gp2"] } } output "ami_id" { value = data.aws_ami.example.id }
Attempts:
2 left
💡 Hint
The 'id' attribute returns the AMI identifier found by the data source.
✗ Incorrect
The data source returns the latest AMI matching the filter, and 'id' outputs its unique AMI identifier string.
❓ Architecture
advanced3:00remaining
Choosing AMI Lookup Strategy for Multi-Region Deployment
You want to deploy identical infrastructure in multiple AWS regions using Terraform. Which approach ensures you get the correct latest AMI in each region?
Options:
Options:
Attempts:
2 left
💡 Hint
Think about how Terraform handles multiple regions and provider aliases.
✗ Incorrect
Using provider aliases for each region and separate data sources ensures Terraform queries the correct AMI per region dynamically.
❓ security
advanced2:00remaining
Security Implications of AMI Lookup Without Owner Restriction
What is a potential security risk of using the 'aws_ami' data source without specifying the 'owners' attribute when looking up an AMI by name pattern?
Attempts:
2 left
💡 Hint
Consider who can publish AMIs and how filtering by owner helps.
✗ Incorrect
Without restricting owners, Terraform may pick an AMI from any AWS account, including potentially malicious ones.
❓ service_behavior
expert2:30remaining
Effect of 'most_recent' Attribute in AMI Lookup
What happens if you set 'most_recent = false' in the 'aws_ami' data source with multiple AMIs matching the filter?
Example:
Example:
data "aws_ami" "example" {
most_recent = false
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-gp2"]
}
}Terraform
data "aws_ami" "example" { most_recent = false owners = ["amazon"] filter { name = "name" values = ["amzn2-ami-hvm-*-x86_64-gp2"] } }
Attempts:
2 left
💡 Hint
Check the documentation for 'most_recent' default behavior.
✗ Incorrect
When 'most_recent' is false, Terraform returns the first AMI it finds matching the filter, which may not be the newest.