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

  environment         = var.environment
  application_family  = var.application_family
  use_container_image = true
  lambda_name         = "${var.lambda_service_name}-error-reporting"
  lambda_description  = "Reports about lambda error caught by step function"


  lambda_function_environment_variables = {
    Environment = var.environment
    SENTRY_DSN  = module.sentry_lambda_assets_error_reporting.sentry_key_dsn_public_output
  }

  lambda_function_timeout                        = "300"
  lambda_function_memory_size                    = "512"
  vpc_enabled                                    = true
  vpc_id                                         = module.vpc_info.vpc_id
  vpc_subnet_ids                                 = module.vpc_info.default_private_subnet_ids
  lambda_function_reserved_concurrent_executions = local.max_concurrency
  datadog_advanced_enabled                       = true
  datadog_enabled                                = true
  iam_managed_policy_attachments                 = []
}

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

  environment        = var.environment
  service_name       = "${var.lambda_service_name}-error-reporting-v2" # v2 to differentiate from old sentry project"
  application_family = var.application_family
}

module "datadog_lambda_assets_error_reporting" {
  source = "git@github.com:theorchard/terraform-datadog.git//modules/lambda?ref=6.10.9"

  environment                       = var.environment
  service_name                      = "${var.lambda_service_name}-error-reporting"
  lambda_invocation_monitor_enabled = false
  lambda_error_monitor_enabled      = true
  notification_endpoints            = var.notification_endpoints
}
