Skip to content

Instantly share code, notes, and snippets.

@nhammad
Created August 15, 2022 17:05
Show Gist options
  • Save nhammad/795a33ee26a6fba006eb7483e9f63c17 to your computer and use it in GitHub Desktop.
Save nhammad/795a33ee26a6fba006eb7483e9f63c17 to your computer and use it in GitHub Desktop.
resource "aws_sns_topic" "turn-off-topic" {
name = local.topic_name
}
resource "aws_sns_topic_subscription" "turn-off-subscrtion" {
topic_arn = aws_sns_topic.turn-off-topic.arn
protocol = "lambda"
endpoint = aws_lambda_function.processing_lambda.arn
}
resource "aws_lambda_permission" "allow_lambda_access" {
statement_id = "AllowExecutionFromSNS"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.processing_lambda.function_name
principal = "sns.amazonaws.com"
source_arn = aws_sns_topic.turn-off-topic.arn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment