terraform {
  backend "s3" {
    bucket  = "dev-orcd-terraform-state"
    key     = "dev/resonance-engine/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

# default_tags module requires running inside terraform-infra repo path.
# Define equivalent tags locally until this config migrates to terraform-infra.
locals {
  default_tags = {
    environment                 = var.environment
    application_family          = var.application_family
    service_name                = var.service_name
    terraformed                 = "true"
    terraform_github_repository = "terraform-infra"
    terraform_github_path       = "dev/resonance-engine"
  }
}

provider "aws" {
  region = var.aws_region

  default_tags {
    tags = local.default_tags
  }
}

module "vpc_info" {
  source      = "git@github.com:theorchard/terraform-vpc-info.git//?ref=3.1.0"
  environment = var.environment
}

data "aws_caller_identity" "current" {}

# -----------------------------------------------------------------------------
# Networking Provider — required by terraform-fargate module (aws.dns alias)
# The module declares aws.dns as a configuration_aliases required provider.
# In worker task_type mode no Route53 records are created, but the alias must
# still be passed. In prod (terraform-infra) this would use profile = "networking"
# for the dedicated networking account.
# -----------------------------------------------------------------------------

provider "aws" {
  alias  = "networking"
  region = var.aws_region

  default_tags {
    tags = local.default_tags
  }
}
