locals {
    common = { 
      project_name   = var.project_name
      project_code   = var.project_code
      service_name   = var.service_name
      environment    = var.environment
      aws_profile    = var.aws_profile
      aws_account_id = var.aws_account_id
      aws_region     = var.aws_region
      default_tags = {
          project_name      = var.project_name
          project_code      = var.project_code
          service_name      = var.service_name
          environment       = var.environment
          terraform_managed = true
      }
    }
}

terraform {
  backend "local" {
    path = "../.terraform-local/${ENVIRONMENT}/terraform.tfstate"
  }
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region                   = local.common.aws_region
  shared_credentials_files = ["~/.aws/credentials"]
  profile                  = local.common.aws_profile
}
