# Lambda defintion for send_org_invite_email step

# allow making owsrequests from lambda
module "lambda_send_org_invite_email_owsrequest" {
  source = "git@github.com:theorchard/terraform-owsrequest.git?ref=1.1.0"

  environment_name = var.environment
  service_name     = "lambda-send-org-invite-email"
}

# lambda defination
module "lambda_send_org_invite_email" {
  source = "git@github.com:theorchard/terraform-lambda.git//?ref=5.2.1"

  environment              = var.environment
  use_container_image      = true
  lambda_name              = "lambda-send-org-invite-email"
  lambda_description       = "For send_org_invite_email step in step function."
  application_family       = var.application_family
  datadog_advanced_enabled = var.datadog_advanced_enabled

  lambda_function_environment_variables = {
    Environment = var.environment
    LOGGER_DSN  = var.logger_dsn
    SENTRY_DSN  = module.sentry_gda_account_creation.sentry_key_dsn_public_output
  }

  lambda_function_timeout                        = var.lambda_default_timeout
  vpc_id                                         = module.vpc_info.vpc_id
  vpc_subnet_ids                                 = module.vpc_info.default_private_subnet_ids
  lambda_function_reserved_concurrent_executions = var.lambda_concurrent_executions
  datadog_enabled                                = var.datadog_enabled

  iam_managed_policy_attachments = [
    module.lambda_send_org_invite_email_owsrequest.policy_arn_output
  ]
}


# stage datadog creds and create dashboards.
module "datadog_lambda_send_org_invite_email_lambda" {
  source = "git@github.com:theorchard/terraform-datadog.git//modules/lambda?ref=6.15.3"

  environment                       = var.environment
  service_name                      = "lambda-send-org-invite-email"
  lambda_invocation_monitor_enabled = false
}
