# This bucket is the S3 replacement for SFTP file ingestion currently handled
# by the EC2/NLB slaughterhouse service (accounting/qa/slaughterhouse/).
# The slaughterhouse SFTP path (NLB port 22 -> EC2) remains active until all
# producers are migrated.
#
# Human access via application_family accounting (see prod/github/revenue-file-ingestion/):
#   prod/iam/groups/accounting -> accounting-role (989790945997)
#   accounting/qa/iam/application-family/accounting (*-revenue-file-ingestion*)

provider "aws" {
  region = var.aws_region
}

# Terraform backends cannot contain interpolations
terraform {
  backend "s3" {
    bucket  = "qa-accounting-terraform-state"
    key     = "qa/revenue-file-ingestion/terraform.tfstate"
    region  = "us-east-1"
    encrypt = true
  }
}

module "s3_bucket" {
  source = "git@github.com:theorchard/terraform-s3.git//modules/s3_bucket?ref=3.15.7"

  env                = var.environment
  bucket_name        = var.bucket_name
  application_family = var.application_family

  apply_server_side_encryption_by_default = {
    sse_algorithm = "AES256"
  }

  block_public_access = true

  lifecycle_rules_options_current_version_transition = [
    {
      prefix        = ""
      enabled       = true
      days          = 0
      storage_class = "INTELLIGENT_TIERING"
    },
  ]
}

