# Lambda function for the encoding route step
module "encoding_route_lambda" {
  source = "git@github.com:theorchard/terraform-lambda.git//?ref=3.1.4"

  application_family  = var.application_family
  environment         = var.environment
  lambda_name         = "asset-transcoder-encoding-route"
  use_container_image = true
  lambda_description  = "Determines the media type of the given asset and branches to either the audio or image flow"

  lambda_function_environment_variables = merge({
    Environment                  = var.environment
    SNS_GENERAL_STATUS_TOPIC_ARN = module.sns_general_status.proxied_sns_arn
    LOGGER_DSN                   = "udp://${var.environment}-fluentd-applications-udp.theorchard.io:5160"
  }, var.lambda_additional_environment_variables)

  lambda_function_timeout                        = var.lambda_default_timeout
  vpc_id                                         = var.vpc_id
  vpc_subnet_ids                                 = var.vpc_subnet_ids
  lambda_function_reserved_concurrent_executions = var.lambda_concurrent_executions
  datadog_enabled                                = var.datadog_enabled
  iam_policy_file_enabled                        = false
  iam_managed_policy_attachments = [
    aws_iam_policy.common_lambda_policy.arn,
  ]
}
