terraform {
  backend "s3" {
    bucket                  = "gdb-apollo-prod-tfstate"
    key                     = "Security/security.tfstate"
    region                  = "us-east-1"
    shared_credentials_file = "~/.aws/credentials"
    profile                 = "gdb-apollo-prod"
  }
}

provider "aws" {
  region  = "eu-west-1"
  alias   = "eu_west_1"
  profile = "gdb-apollo-prod"
}

module "security" {
  source                    = "../../modules/security_v3.0"
  sqs_sse_enable            = true
  sns_sse_enable            = true
  gd_publishing_s3          = true
  admin_users               = var.admin_users
  aws_profile               = "gdb-apollo-prod"
  platform                  = var.platform
  sqs_kms_trust_accounts    = ["323555055331"]
  common_tags               = var.tags
  enable_cloudtrail_logging = false
}

resource "aws_guardduty_detector" "guardduty_eu_west_1" {
  provider = aws.eu_west_1
  enable   = true
}

resource "aws_guardduty_publishing_destination" "s3_destination_eu_west_1" {
  provider        = aws.eu_west_1
  detector_id     = aws_guardduty_detector.guardduty_eu_west_1.id
  destination_arn = "${module.security.guardduty_logs_s3_arn}/gd"
  kms_key_arn     = module.security.guardduty_kms_key_arn
}
