Skip to content

Commit cfdfc41

Browse files
authored
feat: event source mapping metrics support (#169)
1 parent 6c29450 commit cfdfc41

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

event_source_mappings.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ resource "aws_lambda_event_source_mapping" "event_source" {
7272
}
7373
}
7474

75+
dynamic "metrics_config" {
76+
for_each = try([each.value.metrics_config], [])
77+
78+
content {
79+
metrics = metrics_config.value.metrics
80+
}
81+
}
82+
7583
dynamic "scaling_config" {
7684
for_each = try(each.value.scaling_config, null) != null ? [true] : []
7785

examples/with-event-source-mappings/dynamodb-with-alias/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ module "lambda" {
8181
// see https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html
8282
destination_arn_on_failure = aws_sqs_queue.errors.arn
8383

84-
8584
// Lambda event filtering, see https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html
8685
filter_criteria = [
8786
{
@@ -99,6 +98,11 @@ module "lambda" {
9998
})
10099
}
101100
]
101+
102+
// Event source mapping metrics, see https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html#event-source-mapping-metrics
103+
metrics_config = {
104+
metrics = ["EventCount"]
105+
}
102106
}
103107

104108
table_2 = {

examples/with-event-source-mappings/kinesis/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ module "lambda" {
6565
})
6666
}
6767
]
68+
69+
// Event source mapping metrics, see https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html#event-source-mapping-metrics
70+
metrics_config = {
71+
metrics = ["EventCount"]
72+
}
6873
}
6974

7075
stream_2 = {

examples/with-event-source-mappings/sqs/main.tf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ module "lambda" {
4545
// optionally overwrite arguments from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping
4646
batch_size = 5
4747

48-
scaling_config = {
49-
maximum_concurrency = 2
50-
}
51-
5248
// Lambda event filtering, see https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html
5349
filter_criteria = [
5450
{
@@ -66,6 +62,15 @@ module "lambda" {
6662
})
6763
}
6864
]
65+
66+
// Event source mapping metrics, see https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html#event-source-mapping-metrics
67+
metrics_config = {
68+
metrics = ["EventCount"]
69+
}
70+
71+
scaling_config = {
72+
maximum_concurrency = 2
73+
}
6974
}
7075

7176
queue_2 = {

0 commit comments

Comments
 (0)