provider "aws" {
  region = var.aws_region
}

data "aws_caller_identity" "current" {}

terraform {
  backend "s3" {
    bucket  = "orcd-terraform-state"
    key     = "prod/lambda-distro-support/merge-label-participants/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

# for aura and split credentials
module "secrets" {
  source   = "git@github.com:theorchard/terraform-secrets-manager.git//?ref=1.5.1"
  for_each = toset(var.secrets_manager_secret_names)

  environment        = var.environment
  service_name       = var.lambda_name
  secret_name        = each.value
  application_family = var.application_family
}

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

  lambda_name                                    = var.lambda_name
  lambda_description                             = "Merge Label Participant nodes in neo4j"
  environment                                    = var.environment
  application_family                             = var.application_family
  lambda_function_reserved_concurrent_executions = var.lambda_concurrent_executions
  lambda_function_timeout                        = var.lambda_default_timeout
  use_container_image                            = true
  vpc_id                                         = var.vpc_id
  vpc_subnet_ids                                 = var.vpc_subnet_ids

  lambda_function_environment_variables = {
    Environment = var.environment
  }
  datadog_function_destination_lambda_name = "DatadogLambdaFunction"
}

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

  environment  = var.environment
  platform     = "python"
  service_name = var.lambda_name
  application_family = var.application_family
}

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

  environment                       = var.environment
  service_name                      = var.lambda_name
  lambda_invocation_monitor_enabled = false
  notification_endpoints            = var.notification_endpoints
}
