############################################
# Load FastAPI Terraform State
############################################
data "terraform_remote_state" "fast_api" {
  backend = "s3"
  config = {
    bucket = "ara-fast-api-terraform-state"
    key    = "env:/${var.stage}/terraform.tfstate"
    region = "eu-west-2"
  }
}

############################################
# Define Certificate
############################################
module "cdn_certificate" {
  source = "../modules/acm_certificate"

  providers = {
    aws = aws.us_east_1
  }

  domain_name = data.terraform_remote_state.fast_api.outputs.domain_name

  tags = {
    Environment = var.stage
  }
}