// This is an example HCL configuration file for testing various software configurations # Another line comment style /* This is a multi-line comment block. It starts with a slash and a star, and ends with a star and a slash. */ // Terraform block terraform { required_version = ">= 1.0.0" required_providers { aws = { source = "hashicorp/aws" version = "~> 4.0" } } backend "s3" { bucket = "my-terraform-state" key = "test-app/terraform.tfstate" region = "us-west-2" } } // Variable Definitions variable "app_name" { description = "The name of the application" type = string default = "TestApp" } variable "instance_count" { description = "Number of instances to deploy" type = number default = 3 } variable "enable_feature_x" { description = "Enable feature X" type = bool default = true } variable "admins" { description = "List of admin users" type = list(string) default = ["alice", "bob"] } // Locals locals { app_env = "testing" version = "1.0.0" } // Providers provider "aws" { region = "us-west-2" } // Data Sources data "aws_ami" "latest_ubuntu" { most_recent = true owners = ["self"] filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"] } } // Resources resource "aws_instance" "app_server" { count = var.instance_count ami = data.aws_ami.latest_ubuntu.id instance_type = "t2.micro" tags = { Name = "${var.app_name}-${count.index}" Environment = local.app_env Version = local.version } // Dynamic block for user data dynamic "user_data" { for_each = var.enable_feature_x ? [1] : [] content { data = <