0
0
Terraformcloud~10 mins

Data source block syntax in Terraform - Interactive Code Practice

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

Complete the code to declare a data source block for AWS AMI.

Terraform
[1] "aws_ami" "example" {
  most_recent = true
  owners      = ["amazon"]
}
Drag options to blanks, or click blank then click option'
Adata
Bresource
Csource
Dprovider
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'resource' instead of 'data' to declare a data source block.
Using 'source' or 'provider' which are incorrect keywords here.
2fill in blank
medium

Complete the code to specify the data source name for AWS VPC.

Terraform
data "aws_vpc" [1] {
  default = true
}
Drag options to blanks, or click blank then click option'
Amain
Bdefault
Cvpc_id
Ddefault_vpc
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute names like 'vpc_id' as the data source name.
Using names that are not valid identifiers or confusing keywords.
3fill in blank
hard

Fix the error in the data source block by completing the missing attribute.

Terraform
data "aws_subnet" default_subnet {
  [1] = "subnet-12345678"
}
Drag options to blanks, or click blank then click option'
Asubnet
Bid
Csubnet_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'subnet_id' which causes Terraform to error.
Using 'name' or 'subnet' which are not valid attributes here.
4fill in blank
hard

Fill both blanks to complete the data source block that fetches the latest Amazon Linux AMI.

Terraform
data "aws_ami" [1] {
  most_recent = true
  filter {
    name   = "name"
    values = ["[2]"]
  }
  owners = ["amazon"]
}
Drag options to blanks, or click blank then click option'
Aamazon_linux
Bamzn2-ami-hvm-2.0.*-x86_64-gp2
Clatest_ami
Damzn-ami-hvm-2018.03.0.20181129-x86_64-gp2
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect or outdated AMI name pattern in the filter.
Using a generic or unrelated name for the data source identifier.
5fill in blank
hard

Fill all three blanks to complete the data source block that fetches a subnet by its tag.

Terraform
data "aws_subnet" [1] {
  filter {
    name   = "tag:[2]"
    values = ["[3]"]
  }
}
Drag options to blanks, or click blank then click option'
Aselected_subnet
BEnvironment
Cproduction
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect tag keys or values that do not exist.
Using generic names that do not clearly identify the data source.