Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sns #86

Merged
merged 3 commits into from
Mar 6, 2024
Merged

Sns #86

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions modules/scenarios/sns_lambda.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This example is to detect that we can show that Overmind will be able to
# detect that removing an SNS topic will affect a lambda even if it's not
# managed in terraform

data "archive_file" "lambda_zip" {
type = "zip"
output_path = "${path.module}/tmp/lambda_function.zip"

source {
content = <<EOF
exports.handler = async (event) => {
console.log("Event: ", event);
return {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
};
EOF
filename = "index.js"
}
}

resource "aws_iam_role" "lambda_iam_role" {
name = "example_lambda_iam_role"

assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Principal = {
Service = "lambda.amazonaws.com",
},
Effect = "Allow",
Sid = "",
},
],
})
}

resource "aws_lambda_function" "example" {
function_name = "example_lambda_function"
filename = data.archive_file.lambda_zip.output_path
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
role = aws_iam_role.lambda_iam_role.arn
handler = "index.handler"
runtime = "nodejs20.x"
}

resource "aws_sns_topic" "example_topic" {
name = "example-topic"
}

# resource "aws_lambda_permission" "allow_sns" {
# statement_id = "AllowExecutionFromSNS"
# action = "lambda:InvokeFunction"
# function_name = aws_lambda_function.example.function_name
# principal = "sns.amazonaws.com"
# source_arn = aws_sns_topic.example_topic.arn
# }
Binary file added modules/scenarios/tmp/lambda_function.zip
Binary file not shown.