Skip to content

Commit 2b5f1ef

Browse files
authored
feat: Updated version of Terraform AWS Lambda module to support multiple copies (#117)
1 parent abef34f commit 2b5f1ef

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.43.0
3+
rev: v1.44.0
44
hooks:
55
- id: terraform_fmt
6+
- id: terraform_validate
67
- id: terraform_docs
78
- id: terraform_tflint
89
args:
@@ -20,6 +21,6 @@ repos:
2021
- '--args=--only=terraform_standard_module_structure'
2122
- '--args=--only=terraform_workspace_remote'
2223
- repo: git://github.com/pre-commit/pre-commit-hooks
23-
rev: v3.2.0
24+
rev: v3.3.0
2425
hooks:
2526
- id: check-merge-conflict

examples/cloudwatch-alerts-to-slack/main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ resource "aws_kms_ciphertext" "slack_url" {
1616
module "notify_slack" {
1717
source = "../../"
1818

19+
for_each = toset([
20+
"develop",
21+
"release",
22+
"test",
23+
])
24+
1925
sns_topic_name = "slack-topic"
2026

27+
lambda_function_name = "notify_slack_${each.value}"
28+
2129
slack_webhook_url = aws_kms_ciphertext.slack_url.ciphertext_blob
2230
slack_channel = "aws-notification"
2331
slack_username = "reporter"
@@ -43,9 +51,9 @@ resource "aws_cloudwatch_metric_alarm" "lambda_duration" {
4351
threshold = "5000"
4452
alarm_description = "Duration of notifying slack exceeds threshold"
4553

46-
alarm_actions = [module.notify_slack.this_slack_topic_arn]
54+
alarm_actions = [module.notify_slack["develop"].this_slack_topic_arn]
4755

4856
dimensions = {
49-
FunctionName = module.notify_slack.notify_slack_lambda_function_name
57+
FunctionName = module.notify_slack["develop"].notify_slack_lambda_function_name
5058
}
5159
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
output "this_sns_topic_arn" {
22
description = "The ARN of the SNS topic from which messages will be sent to Slack"
3-
value = module.notify_slack.this_slack_topic_arn
3+
value = module.notify_slack["develop"].this_slack_topic_arn
44
}
55

66
output "lambda_iam_role_arn" {
77
description = "The ARN of the IAM role used by Lambda function"
8-
value = module.notify_slack.lambda_iam_role_arn
8+
value = module.notify_slack["develop"].lambda_iam_role_arn
99
}
1010

1111
output "lambda_iam_role_name" {
1212
description = "The name of the IAM role used by Lambda function"
13-
value = module.notify_slack.lambda_iam_role_name
13+
value = module.notify_slack["develop"].lambda_iam_role_name
1414
}
1515

1616
output "notify_slack_lambda_function_arn" {
1717
description = "The ARN of the Lambda function"
18-
value = module.notify_slack.notify_slack_lambda_function_arn
18+
value = module.notify_slack["develop"].notify_slack_lambda_function_arn
1919
}
2020

2121
output "notify_slack_lambda_function_name" {
2222
description = "The name of the Lambda function"
23-
value = module.notify_slack.notify_slack_lambda_function_name
23+
value = module.notify_slack["develop"].notify_slack_lambda_function_name
2424
}
2525

2626
output "notify_slack_lambda_function_invoke_arn" {
2727
description = "The ARN to be used for invoking Lambda function from API Gateway"
28-
value = module.notify_slack.notify_slack_lambda_function_invoke_arn
28+
value = module.notify_slack["develop"].notify_slack_lambda_function_invoke_arn
2929
}
3030

3131
output "notify_slack_lambda_function_last_modified" {
3232
description = "The date Lambda function was last modified"
33-
value = module.notify_slack.notify_slack_lambda_function_last_modified
33+
value = module.notify_slack["develop"].notify_slack_lambda_function_last_modified
3434
}
3535

3636
output "notify_slack_lambda_function_version" {
3737
description = "Latest published version of your Lambda function"
38-
value = module.notify_slack.notify_slack_lambda_function_version
38+
value = module.notify_slack["develop"].notify_slack_lambda_function_version
3939
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ resource "aws_sns_topic_subscription" "sns_notify_slack" {
6767

6868
module "lambda" {
6969
source = "terraform-aws-modules/lambda/aws"
70-
version = "1.18.0"
70+
version = "1.27.0"
7171

7272
create = var.create
7373

0 commit comments

Comments
 (0)