-
Notifications
You must be signed in to change notification settings - Fork 14
/
lambda.tf
30 lines (25 loc) · 991 Bytes
/
lambda.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
data "archive_file" "lambda_with_dependencies" {
source_dir = "lambda/"
output_path = "lambda/${local.app_name}-${var.lambda_name}.zip"
type = "zip"
}
resource "aws_lambda_function" "lambda_sqs" {
function_name = "${local.app_name}-${var.lambda_name}"
handler = "handler.lambda_handler"
role = aws_iam_role.lambda_exec_role.arn
runtime = "python3.7"
filename = data.archive_file.lambda_with_dependencies.output_path
source_code_hash = data.archive_file.lambda_with_dependencies.output_base64sha256
timeout = 30
memory_size = 128
depends_on = [
aws_iam_role_policy_attachment.lambda_role_policy
]
}
resource "aws_lambda_permission" "allows_sqs_to_trigger_lambda" {
statement_id = "AllowExecutionFromSQS"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.lambda_sqs.function_name
principal = "sqs.amazonaws.com"
source_arn = aws_sqs_queue.queue.arn
}