locals {
  lambda_name_edit_attachments = "${var.service_name}-edit-attachments"
}

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

  environment             = var.environment
  application_family      = var.application_family
  lambda_name             = local.lambda_name_edit_attachments
  lambda_description      = "Removes UPCs/ISRCs from originating contract terms and adds them to destination."
  lambda_function_timeout = "300"
  use_container_image     = true
  vpc_id                  = module.vpc_info.vpc_id
  vpc_subnet_ids          = module.vpc_info.default_private_subnet_ids
  lambda_function_environment_variables = {
    ENVIRONMENT = var.environment
    SENTRY_DSN  = module.sentry_edit_attachments.sentry_key_dsn_public_output
  }
}

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

  environment                       = var.environment
  service_name                      = local.lambda_name_edit_attachments
  notification_endpoints            = var.notification_endpoints
  escalation_notification_endpoints = var.notification_endpoints
}

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

  environment        = var.environment
  service_name       = local.lambda_name_edit_attachments
  application_family = var.application_family
  teams              = [var.environment]
}

module "m2m_secrets_edit_attachments" {
  source = "git@github.com:theorchard/terraform-secrets-manager.git//modules/auth0m2m?ref=1.6.1"

  environment        = var.environment
  service_name       = local.lambda_name_edit_attachments
  application_family = var.application_family
}
