how to create aws lambda trigger in terraform?

Viewed 3553

Can anyone reference or show me an example on how to create a AWS Lambda trigger with Terraform?

In the AWS console, after clicking a function name and selecting the configuration tab, you can create triggers E.g. a SNS trigger

1 Answers

For sns you need to create sns subscription

resource "aws_sns_topic_subscription" "user_updates_lampda_target" {
  topic_arn = “sns topic arn”
  protocol  = "lambda"
  endpoint  = “lambda arn here”
}

To allows Lambda functions to get events from Kinesis, DynamoDB and SQS you can use event source mapping

resource "aws_lambda_event_source_mapping" "example" {
  event_source_arn  = aws_dynamodb_table.example.stream_arn
  function_name     = aws_lambda_function.example.arn
  starting_position = "LATEST"
}
Related