Skip to content

Commit 9c3730b

Browse files
authored
feat: Added destination_config in aws_lambda_event_source_mapping (#152)
1 parent bb35d61 commit 9c3730b

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

examples/event-source-mapping/main.tf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ module "lambda_function" {
2727
event_source_arn = aws_sqs_queue.this.arn
2828
}
2929
dynamodb = {
30-
event_source_arn = aws_dynamodb_table.this.stream_arn
31-
starting_position = "LATEST"
32-
# This can be created but it won't be updated/removed. To be reviewed in the future.
33-
# destination_config = {
34-
# on_failure = {
35-
# destination_arn = aws_sqs_queue.failure.arn
36-
# }
37-
# }
30+
event_source_arn = aws_dynamodb_table.this.stream_arn
31+
starting_position = "LATEST"
32+
destination_arn_on_failure = aws_sqs_queue.failure.arn
3833
}
3934
kinesis = {
4035
event_source_arn = aws_kinesis_stream.this.arn

main.tf

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ resource "aws_lambda_permission" "unqualified_alias_triggers" {
213213
}
214214

215215
resource "aws_lambda_event_source_mapping" "this" {
216-
for_each = var.create && var.create_function && !var.create_layer && var.create_unqualified_alias_allowed_triggers ? var.event_source_mapping : tomap({})
216+
for_each = var.create && var.create_function && !var.create_layer && var.create_unqualified_alias_allowed_triggers ? tomap(var.event_source_mapping) : tomap({})
217217

218218
function_name = aws_lambda_function.this[0].arn
219219

@@ -229,15 +229,12 @@ resource "aws_lambda_event_source_mapping" "this" {
229229
maximum_record_age_in_seconds = lookup(each.value, "maximum_record_age_in_seconds", null)
230230
bisect_batch_on_function_error = lookup(each.value, "bisect_batch_on_function_error", null)
231231

232-
/* @todo: fix this
233232
dynamic "destination_config" {
234-
for_each = lookup(each.value, "destination_config", {})
235-
233+
for_each = lookup(each.value, "destination_arn_on_failure", null) != null ? [true] : []
236234
content {
237235
on_failure {
238-
destination_arn = lookup(destination_config.value, "on_failure") #"destination_arn"]
236+
destination_arn = each.value["destination_arn_on_failure"]
239237
}
240238
}
241239
}
242-
*/
243240
}

0 commit comments

Comments
 (0)