# The attribute `${data.aws_caller_identity.current.account_id}` will be current account number.
data "aws_caller_identity" "current" {}

# The attribue `${data.aws_iam_account_alias.current.account_alias}` will be current account alias
data "aws_iam_account_alias" "current" {}

# According to the security requirements we need to send logs into this bucket.
data "aws_s3_bucket" "security_logs" {
  bucket = "security-${local.account_id}-logs"
}

module "aws_accounts_list" {
  source = "../../../modules/iam/aws_accounts_list"
}

module "tags" {
  source = "../../../modules/tags/defaults_plat_env"

  env_prefix    = var.env_prefix
  project_group = local.project_group
}

locals {
  // Constants
  project_group = "infra"

  name_prefix    = "${var.env_prefix}-${local.project_group}"
  secret_prefix  = "${local.project_group}/${var.env_prefix}"
  account_id     = data.aws_caller_identity.current.account_id
  aggregated_tag = "${module.tags.aggregated_tag}_INFRA"
  account_alias  = data.aws_iam_account_alias.current.account_alias
  accounts       = module.aws_accounts_list.accounts
}
