Skip to content

Commit 9a7a764

Browse files
committed
feat: enable multiple invocations of the module in a single account
1 parent 8144204 commit 9a7a764

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resource aws_lambda_permission slowlog_check {
2020

2121

2222
resource aws_iam_role slowlog_check {
23-
name = "slowlog_check"
23+
name_prefix = "slowlog_check"
2424

2525
assume_role_policy = <<EOF
2626
{
@@ -40,7 +40,7 @@ EOF
4040
}
4141

4242
resource aws_iam_policy slowlog_check {
43-
name = "slowlog_check"
43+
name_prefix = "slowlog_check"
4444
path = "/"
4545
description = "This IAM policy allows the slowlog_check to run"
4646

@@ -95,15 +95,15 @@ resource aws_security_group egress {
9595
}
9696

9797
resource aws_ssm_parameter datadog_api_key {
98-
name = "/${var.ssm_path}/DATADOG_API_KEY"
98+
name = "/${var.ssm_path}/${local.replication_group}/DATADOG_API_KEY"
9999
description = "Datadog API Key"
100100
tags = var.tags
101101
type = "SecureString"
102102
value = var.datadog_api_key
103103
}
104104

105105
resource aws_ssm_parameter datadog_app_key {
106-
name = "/${var.ssm_path}/DATADOG_APP_KEY"
106+
name = "/${var.ssm_path}/${local.replication_group}/DATADOG_APP_KEY"
107107
description = "Datadog App Key"
108108
tags = var.tags
109109
type = "SecureString"
@@ -112,7 +112,7 @@ resource aws_ssm_parameter datadog_app_key {
112112

113113

114114
resource "aws_lambda_function" "slowlog_check" {
115-
function_name = "slowlog_check"
115+
function_name = "slowlog_check_for_${local.replication_group}"
116116
filename = local.slowlog_check_archive_path
117117
source_code_hash = local.slowlog_check_archive_hash
118118
role = aws_iam_role.slowlog_check.arn
@@ -127,7 +127,7 @@ resource "aws_lambda_function" "slowlog_check" {
127127
environment {
128128
variables = {
129129
REDIS_HOST = var.elasticache_endpoint
130-
SSM_PATH = "${var.ssm_path}"
130+
SSM_PATH = "${var.ssm_path}/${local.replication_group}"
131131
NAMESPACE = var.namespace
132132
ENV = var.env
133133
METRICNAME = var.metric_name

vars.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ variable metric_name {
3939
}
4040

4141
variable ssm_path {
42-
description = "Custom SSM path to provision Datadog access ID's in. Leading slash ommitted."
42+
description = "Custom SSM path to provision Datadog access ID's in. Leading slash ommitted. The final SSM paths will look like: `/$ssm_path/$elasticache_endpoint/DATADOG_API_KEY`"
4343
default = "slowlog_check"
4444
}
4545

0 commit comments

Comments
 (0)