module "lambda_sr_fanout_sentry_project" {
  source = "git@github.com:theorchard/terraform-sentry.git?ref=4.1.2"

  application_family = var.application_family
  environment        = var.environment
  platform           = "python"
  service_name       = var.sr_fanout_function_name
  teams              = [var.environment]
}

module "lambda_sr_fanout_owsrequest" {
  source = "git@github.com:theorchard/terraform-owsrequest.git//?ref=1.1.0"

  environment_name = var.environment
  service_name     = var.sr_fanout_function_name
}

module "lambda_sr_fanout" {
  source = "git@github.com:theorchard/terraform-lambda.git//?ref=4.2.0"

  application_family       = var.application_family
  datadog_advanced_enabled = true
  environment              = var.environment
  lambda_name              = var.sr_fanout_function_name
  lambda_description       = "Logically fanout parent->child relationships"
  lambda_function_timeout  = var.lambda_max_timeout
  use_container_image      = true
  vpc_id                   = var.vpc_id
  vpc_subnet_ids           = var.vpc_subnet_ids

  iam_managed_policy_attachments = [
    module.lambda_sr_fanout_owsrequest.policy_arn_output
  ]

  lambda_function_environment_variables = {
    ENVIRONMENT = var.environment
  }

  lambda_function_reserved_concurrent_executions = "20"
}

module "datadog_lambda_sr_fanout_dashboards" {
  source                            = "git@github.com:theorchard/terraform-datadog.git//modules/lambda?ref=6.18.1"
  service_name                      = var.sr_fanout_function_name
  environment                       = var.environment
  lambda_invocation_monitor_enabled = false
  lambda_error_monitor_enabled      = true
  notification_endpoints            = var.notification_endpoints
  teams                             = var.teams
}
