<commit_before>
resource "aws_lambda_function" "craftbot_function" {
  s3_bucket               = "${aws_s3_bucket.latcraft_code.bucket}"
  s3_key                  = "event-manager.zip"
  function_name           = "craftbot_function"
  description             = "CraftBot"
  role                    = "${aws_iam_role.latcraft_lambda_executor.arn}"
  handler                 = "${var.lambda_code_package_prefix}.router.CraftBotCommands::${var.lambda_code_default_method}"
  runtime                 = "java8"
  memory_size             = "512"
  timeout                 = "300"
  kms_key_arn             = "${aws_kms_key.latcraft_kms_key.arn}"
  environment {
    variables = {
      HOME                = "/var/task"
      JAVA_FONTS          = "/var/task/fonts"
    }
  }
}

resource "aws_lambda_alias" "craftbot_function_alias" {
  name                    = "craftbot_function_latest"
  function_name           = "${aws_lambda_function.craftbot_function.arn}"
  function_version        = "$LATEST"
}

// TODO: implement cloudwatch schedule to keep lambda warm<commit_msg>added cloudwatch schedule to ping craftbot router<commit_after>
resource "aws_lambda_function" "craftbot_function" {
  s3_bucket               = "${aws_s3_bucket.latcraft_code.bucket}"
  s3_key                  = "event-manager.zip"
  function_name           = "craftbot_function"
  description             = "CraftBot"
  role                    = "${aws_iam_role.latcraft_lambda_executor.arn}"
  handler                 = "${var.lambda_code_package_prefix}.router.CraftBotCommands::${var.lambda_code_default_method}"
  runtime                 = "java8"
  memory_size             = "512"
  timeout                 = "300"
  kms_key_arn             = "${aws_kms_key.latcraft_kms_key.arn}"
  environment {
    variables = {
      HOME                = "/var/task"
      JAVA_FONTS          = "/var/task/fonts"
    }
  }
}

resource "aws_lambda_alias" "craftbot_function_alias" {
  name                    = "craftbot_function_latest"
  function_name           = "${aws_lambda_function.craftbot_function.arn}"
  function_version        = "$LATEST"
}

resource "aws_cloudwatch_event_rule" "craftbot_warm_up" {
  name        = "craftbot_warm_up"
  description = "Ping CraftBot to keep it warm"
  schedule_expression = "rate(15 minutes)"
}

resource "aws_cloudwatch_event_target" "craftbot_warm_up" {
  rule      = "${aws_cloudwatch_event_rule.craftbot_warm_up.name}"
  target_id = "craftbot_warm_up"
  arn       = "${aws_lambda_function.craftbot_function.arn}"
  input     = <<INPUT
{
  "ping": "true"
}
INPUT
}
{'fraction_non_alphanumeric': 0.10287267080745342, 'fraction_numerical': 0.008540372670807454, 'mean_word_length': 2.3166023166023164, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6618730', 'n_tokens_mistral': 831, 'n_tokens_neox': 802, 'n_words': 120}