Skip to content

Event sources and SNS subscriptions

Compare
Choose a tag to compare
@moritzzimmer moritzzimmer released this 13 Jan 14:26

New Features

Possibilities to configure SNS subscriptions and event source mappings for Dynamodb, Kinesis and SQS have been enhanced with this release.

Event source mappings

A new variable event_source_mappings has been introduced. The new configuration supports:

  • configuration of N event sources instead of only one
  • using Lambda aliases in event source mappings
  • event sources like SQS queues or Dynamodb tables can be part of the same terraform stack as resources
  • inline configuration of attributes of event source mappings like batch_size
  • required IAM permissions depending on the event source type will be generated

simple example

module "lambda" {
  event_source_mappings = {
    queue_1 = {
      event_source_arn = aws_sqs_queue.queue_1.arn
    }
    queue_2 = {
      event_source_arn = aws_sqs_queue.queue_2.arn
    }
  }
}

see examples for further details.

SNS subscriptions

A new variable sns_subscriptions has been introduced. The new configuration supports:

  • configuration of N subscriptions instead of only one
  • using Lambda aliases in subscriptions
  • SNS topics can be part of the same terraform stack as resources
  • required permissions to trigger Lambda by SNS will be generated

simple example

module "lambda" {
  sns_subscriptions = {
    topic_1 = {
      topic_arn = aws_sns_topic.topic_1.arn
    }

    topic_2 = {
      topic_arn = aws_sns_topic.topic_2.arn
    }
  }
}

see example for further details.

Deprecations

Using the event variable to configure sns, dynamodb, kinesis and sqs terraform sub-modules is deprecated and will be removed in the next major release. Users should be able to migrate to the new variables without downtime.

Special thanks

Thanks @machadovilaca for providing the new sns subscriptions implementation!

Misc

  • new/updated examples have been enhanced to contain working nodejs12.x handlers for real world testing
  • first terratest for new event source implementation

What's Changed

New Contributors

Full Changelog: v5.7.0...v5.8.0