Skip to content

Commit c9142ea

Browse files
authored
fix: duplicate mr count in fallback channel
1 parent c0d38ad commit c9142ea

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

main.tf

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
22
layer_description = var.layer_description == null ? "Used by Lambda function '${var.function_name}'." : var.layer_description
3-
function_description = var.function_description == null ? "Notifies a Slack workspace about GitLab merge requests that haven't been updated within ${var.stale_days_threshold} days." : var.function_description
43
role_description = var.role_description == null ? "Used by Lambda function '${var.function_name}'." : var.role_description
54
cloudwatch_event_rule_description = var.cloudwatch_event_rule_description == null ? "Used by Lambda function '${var.function_name}'." : var.cloudwatch_event_rule_description
65
ssm_parameter_slack_token_name = var.ssm_parameter_slack_token_name == null ? "/${var.function_name}/slack-token" : var.ssm_parameter_slack_token_name
@@ -11,16 +10,16 @@ locals {
1110

1211
resource "null_resource" "this" {
1312
triggers = {
14-
shell_hash = sha256(file("${path.module}/files/requirements.txt"))
15-
runtime = var.runtime
13+
shell_hash = sha256(file("${path.module}/files/requirements.txt"))
14+
packages_exists = length(fileset("${path.module}/files/packages/python/lib/${var.runtime}/site-packages", "*")) > 0
1615
}
1716

1817
provisioner "local-exec" {
1918
command = <<EOF
20-
rm -rf ${path.module}/files/packages/*
21-
mkdir -p ${path.module}/files/packages/python/lib/${var.runtime}/site-packages
22-
python3 -m pip install -r ${path.module}/files/requirements.txt -t ${path.module}/files/packages/python/lib/${var.runtime}/site-packages
23-
EOF
19+
rm -rf ${path.module}/files/packages/*
20+
mkdir -p ${path.module}/files/packages/python/lib/${var.runtime}/site-packages
21+
python3 -m pip install -r ${path.module}/files/requirements.txt -t ${path.module}/files/packages/python/lib/${var.runtime}/site-packages
22+
EOF
2423
interpreter = ["/bin/bash", "-c"]
2524
}
2625
}
@@ -51,7 +50,7 @@ data "archive_file" "code" {
5150
resource "aws_lambda_function" "this" {
5251
filename = data.archive_file.code.output_path
5352
function_name = var.function_name
54-
description = local.function_description
53+
description = var.description
5554
role = aws_iam_role.this.arn
5655
handler = "lambda.check_and_notify_stale_merge_requests"
5756
runtime = var.runtime
@@ -81,6 +80,8 @@ resource "aws_lambda_function" "this" {
8180
}
8281
}
8382

83+
tags = merge(var.tags, var.function_tags)
84+
8485
depends_on = [aws_cloudwatch_log_group.lambda]
8586
}
8687

@@ -149,6 +150,8 @@ resource "aws_cloudwatch_log_group" "lambda" {
149150
name = "/aws/lambda/${var.function_name}"
150151
retention_in_days = var.cloudwatch_logs_retention_in_days
151152
kms_key_id = var.cloudwatch_logs_kms_key_id
153+
154+
tags = merge(var.tags, var.cloudwatch_logs_tags)
152155
}
153156

154157
resource "aws_ssm_parameter" "slack_token" {

0 commit comments

Comments
 (0)