0
0
Terraformcloud~10 mins

File naming conventions (.tf files) 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 name a Terraform configuration file correctly.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
}

# Save this configuration in a file named [1]
Drag options to blanks, or click blank then click option'
Aterraform.doc
Bconfig.txt
Cmain.tf
Dscript.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Using file extensions like .txt or .doc which are not valid for Terraform.
Naming files with script extensions like .sh.
2fill in blank
medium

Complete the code to name a Terraform variables file correctly.

Terraform
# Variables for Terraform
variable "region" {
  description = "AWS region"
  type        = string
}

# Save this in [1]
Drag options to blanks, or click blank then click option'
Avariables.tf
Bvars.txt
Cvariables.json
Dvars.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Using .txt or .json extensions for variable files.
Naming variable files with shell script extensions.
3fill in blank
hard

Fix the error in the file naming for Terraform outputs.

Terraform
# Outputs configuration
output "instance_ip" {
  value = aws_instance.example.public_ip
}

# This should be saved as [1]
Drag options to blanks, or click blank then click option'
Aoutputs.txt
Boutput.sh
Coutput.json
Doutputs.tf
Attempts:
3 left
💡 Hint
Common Mistakes
Using .txt or .json extensions for output files.
Naming output files with shell script extensions.
4fill in blank
hard

Fill both blanks to correctly name Terraform files for provider and backend configuration.

Terraform
# Provider configuration
provider "aws" {
  region = "us-west-2"
}

# Save this in [1]

# Backend configuration
terraform {
  backend "s3" {
    bucket = "mybucket"
    key    = "path/to/my/key"
    region = "us-west-2"
  }
}

# Save this in [2]
Drag options to blanks, or click blank then click option'
Aprovider.tf
Bbackend.txt
Cbackend.tf
Dprovider.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using .txt extension for Terraform configuration files.
Mixing up provider and backend file names.
5fill in blank
hard

Fill all three blanks to correctly name Terraform files for main configuration, variables, and outputs.

Terraform
# Main configuration
resource "aws_s3_bucket" "bucket" {
  bucket = "my-tf-bucket"
  acl    = "private"
}

# Save this in [1]

# Variables
variable "bucket_name" {
  type = string
}

# Save this in [2]

# Outputs
output "bucket_id" {
  value = aws_s3_bucket.bucket.id
}

# Save this in [3]
Drag options to blanks, or click blank then click option'
Amain.tf
Bvariables.tf
Coutputs.tf
Dconfig.tf
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-.tf extensions for any Terraform files.
Confusing file names for variables and outputs.