variable "aws_region" {
  description = "AWS region."
  type        = string
  default     = "us-east-1"
}

variable "environment" {
  description = "Available values: dev, qa, prod."
  type        = string
  default     = "dev"
}

variable "service_name" {
  description = "Name of service."
  type        = string
  default     = "shared"
}

variable "application_family" {
  description = "Application family to which this service belongs."
  type        = string
}

variable "key_policy_overrides" {
  description = "List of IAM policy document JSONs to merge with KMS Key policy. Statements with the same SID will be overridden."
  type        = list(string)
  default     = []
}

variable "enable_key_rotation" {
  type    = bool
  default = true
}

variable "deletion_window_in_days" {
  type    = number
  default = 30
}

variable "authorized_cloudwatch_log_groups" {
  type    = list(string)
  default = ["*"]
}

locals {
  name  = "${var.environment}-${var.service_name}-${var.application_family}"
  alias = "alias/${local.name}"

  cloudwatch_logs_service_identifiers = ["logs.${var.aws_region}.amazonaws.com"]

  authorized_service_identifiers = compact(concat(
    local.cloudwatch_logs_service_identifiers,
  ))

  tags = {
    environment        = var.environment
    service_name       = var.service_name
    application_family = var.application_family
    terraformed        = true
  }
}
