Skip to content

Commit 8416ffe

Browse files
committed
fix(iam): add back some of the kinesis iam
1 parent e199c8a commit 8416ffe

File tree

4 files changed

+41
-69
lines changed

4 files changed

+41
-69
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
resource "aws_iam_role" "lambda_codedeploy_role" {
2+
name = "${local.prefix}-LambdaCodeDeployRole"
3+
assume_role_policy = data.aws_iam_policy_document.codedeploy_assume_role.json
4+
}
5+
6+
7+
resource "aws_iam_role_policy_attachment" "lambda_codedeploy_role" {
8+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda"
9+
#Depending on the service there are different types.
10+
role = aws_iam_role.lambda_codedeploy_role.name
11+
}
12+
13+
resource "aws_iam_role" "lambda_role" {
14+
name = "${local.prefix}-LambdaExecutionRole"
15+
tags = local.tags
16+
assume_role_policy = data.aws_iam_policy_document.lambda_assume.json
17+
}
18+
19+
resource "aws_iam_role_policy_attachment" "lambda_role_xray_write" {
20+
role = aws_iam_role.lambda_role.name
21+
policy_arn = data.aws_iam_policy.aws_xray_write_only_access.arn
22+
}
23+
24+
data "aws_iam_policy_document" "lambda_assume" {
25+
version = "2012-10-17"
26+
27+
statement {
28+
effect = "Allow"
29+
actions = [
30+
"sts:AssumeRole"
31+
]
32+
33+
principals {
34+
identifiers = [
35+
"lambda.amazonaws.com"
36+
]
37+
38+
type = "Service"
39+
}
40+
}
41+
}

infrastructure/user-list-search/metrics.tf

-19
Original file line numberDiff line numberDiff line change
@@ -246,25 +246,6 @@ module "dashboard_alarm" {
246246
merge(local.metrics.list_item_update_lambda.throttles, { metadata = { color = "#ff7f0e", yAxis = "right" } }),
247247
]
248248
},
249-
{
250-
x = 0.0
251-
y = 24.0
252-
width = 12.0
253-
height = 6.0
254-
properties = {
255-
title = "Event Kinesis Consumer"
256-
stacked = false
257-
region = data.aws_region.current.name,
258-
stat = "Average"
259-
period = 60
260-
}
261-
metrics = [
262-
local.metrics.event_consumer_lambda.duration,
263-
local.metrics.event_consumer_lambda.errors,
264-
merge(local.metrics.event_consumer_lambda.iterator_age, { metadata = { yAxis = "right" } })
265-
]
266-
267-
},
268249
{
269250
x = 12.0
270251
y = 24.0

infrastructure/user-list-search/metrics_alarm_definitions.tf

-21
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,6 @@ locals {
118118
ok_actions = []
119119
alarm_actions = []
120120
}
121-
122-
event_consumer_lambda_errors = {
123-
name = "${local.prefix}-EventConsumerLambdaErrors"
124-
description = "More than 1 error for 3 consecutive minutes"
125-
126-
metrics = [
127-
local.metrics.event_consumer_lambda.duration,
128-
local.metrics.event_consumer_lambda.iterator_age,
129-
local.metrics.event_consumer_lambda.errors
130-
]
131-
132-
threshold = 10
133-
operator = ">"
134-
return_data_on_id = local.metrics.event_consumer_lambda.errors.id
135-
// The kinesis consumer lambda that we listen on for item updates has more then 10 errors for 10 consecutive minutes
136-
period = 60
137-
breaches = 10
138-
tags = local.tags
139-
ok_actions = []
140-
alarm_actions = []
141-
}
142121
}
143122

144123
# TODO: EventHandler metrics

infrastructure/user-list-search/metrics_metric_definitions.tf

-29
Original file line numberDiff line numberDiff line change
@@ -70,35 +70,6 @@ locals {
7070
expression = "IF(user_list_import_queue_messages_deleted, user_list_import_queue_messages_deleted, 1)/IF(user_list_import_queue_messages_sent, user_list_import_queue_messages_sent, 1)*100",
7171
}
7272
}
73-
event_consumer_lambda = {
74-
duration = {
75-
id = "event_consumer_lambda_duration"
76-
namespace = "AWS/Lambda"
77-
metric = "Duration"
78-
statistic = "Sum"
79-
dimensions = {
80-
FunctionName = aws_lambda_function.unified_events_consumer.function_name
81-
}
82-
},
83-
errors = {
84-
id = "event_consumer_lambda_errors"
85-
namespace = "AWS/Lambda"
86-
metric = "Errors"
87-
statistic = "Sum"
88-
dimensions = {
89-
FunctionName = aws_lambda_function.unified_events_consumer.function_name
90-
}
91-
},
92-
iterator_age = {
93-
id = "event_consumer_lambda_iterator_age"
94-
namespace = "AWS/Lambda"
95-
metric = "IteratorAge"
96-
statistic = "Sum"
97-
dimensions = {
98-
FunctionName = aws_lambda_function.unified_events_consumer.function_name
99-
}
100-
}
101-
}
10273

10374
list_item_import_lambda = {
10475
invocations = {

0 commit comments

Comments
 (0)