0
0
Terraformcloud~10 mins

Output declaration 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 an output named "instance_ip".

Terraform
output "instance_ip" {
  value = [1]
}
Drag options to blanks, or click blank then click option'
Aaws_instance.example.arn
Baws_instance.example.private_ip
Caws_instance.example.public_ip
Daws_instance.example.id
Attempts:
3 left
💡 Hint
Common Mistakes
Using private_ip instead of public_ip when external access is needed.
Using resource id or arn which are not IP addresses.
2fill in blank
medium

Complete the code to declare an output named "bucket_name" that shows the S3 bucket's name.

Terraform
output "bucket_name" {
  value = [1]
}
Drag options to blanks, or click blank then click option'
Aaws_s3_bucket.mybucket.arn
Baws_s3_bucket.mybucket.bucket
Caws_s3_bucket.mybucket.region
Daws_s3_bucket.mybucket.id
Attempts:
3 left
💡 Hint
Common Mistakes
Using arn or id instead of the bucket name.
Using region which is unrelated to the bucket's name.
3fill in blank
hard

Fix the error in the output declaration to correctly output the instance's ID.

Terraform
output "instance_id" {
  value = aws_instance.example.[1]
}
Drag options to blanks, or click blank then click option'
Ainstance
Binstance_id
Cip_address
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using "instance_id" which is not a valid attribute.
Using "instance" which is the resource name, not an attribute.
4fill in blank
hard

Fill both blanks to declare an output named "db_endpoint" that outputs the database endpoint address.

Terraform
output "db_endpoint" {
  value = [1].[2]
}
Drag options to blanks, or click blank then click option'
Aaws_db_instance.mydb
Baws_db_instance.db
Cendpoint
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong resource name like "db" instead of "mydb".
Using "endpoint" attribute which is not valid; use "address".
5fill in blank
hard

Fill all three blanks to declare an output named "web_url" that outputs the URL combining protocol and instance public IP.

Terraform
output "web_url" {
  value = "http://" + [1].[2] + ":[3]"
}
Drag options to blanks, or click blank then click option'
Aaws_instance.web
Bpublic_ip
C80
Dprivate_ip
Attempts:
3 left
💡 Hint
Common Mistakes
Using private_ip instead of public_ip which is not accessible externally.
Using wrong port number or missing port.