Complete the code to name a Terraform configuration file correctly.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" } # Save this configuration in a file named [1]
The correct file extension for Terraform configuration files is .tf. The common convention is to use main.tf as the primary file name.
Complete the code to name a Terraform variables file correctly.
# Variables for Terraform variable "region" { description = "AWS region" type = string } # Save this in [1]
Terraform variable definitions are conventionally stored in a file named variables.tf with the .tf extension.
Fix the error in the file naming for Terraform outputs.
# Outputs configuration output "instance_ip" { value = aws_instance.example.public_ip } # This should be saved as [1]
Output definitions in Terraform are stored in files with the .tf extension. The common convention is outputs.tf.
Fill both blanks to correctly name Terraform files for provider and backend configuration.
# 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]
Provider configurations are usually saved in provider.tf and backend configurations in backend.tf, both using the .tf extension.
Fill all three blanks to correctly name Terraform files for main configuration, variables, and outputs.
# 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]
The main Terraform configuration file is usually main.tf, variables are in variables.tf, and outputs in outputs.tf.