First, create a file named terraform/variables.tf to define the input variables shared across the entire project. Keeping variables in a separate file makes the configuration easier to customize without modifying the resource definitions directly.
# Defines the AWS Region where the infrastructure resources will be deployed
variable "aws_region" {
description = "AWS region for infrastructure deployment"
type = string
default = "us-east-1"
}
# Defines the current deployment environment of the system
variable "environment" {
description = "Deployment environment (dev/test/prod)"
type = string
default = "dev"
}
# Specifies the project name, which is used as a prefix when naming resources such as Lambda functions, S3 buckets, and IAM roles
variable "project_name" {
description = "Project name, used as a prefix for naming resources"
type = string
default = "cloudcost-insight"
}
# Specifies the email address that will receive alert notifications from the system
variable "alert_email" {
description = "Email address for receiving cost alert via SNS"
type = string
}
# Defines the EventBridge schedule expression that determines how frequently the automated task runs
variable "schedule_expression" {
description = "Scheduled expression for EventBridge"
type = string
default = "rate(1 day)"
}
# Defines the cost threshold in USD
variable "cost_threshold_usd" {
description = "Cost threshold (USD) that triggers an alert"
type = number
default = 10
}