This repository has been archived by the owner on Jun 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lambda.tf
93 lines (92 loc) · 3.4 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
resource "aws_iam_role" "assume_role_lambda" {
name = "assume_role_lambda"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
data "aws_iam_policy_document" "dynamo-access-rw" {
statement {
actions = [
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:UpdateItem",
]
resources = [
"arn:aws:dynamodb:*:*:*",
]
}
}
resource "aws_iam_policy" "dynamo-access-rw" {
name = "dynamo-access-rw"
path = "/"
policy = data.aws_iam_policy_document.dynamo-access-rw.json
}
resource "aws_iam_role_policy_attachment" "dynamo-access-rw" {
role = aws_iam_role.assume_role_lambda.name
policy_arn = aws_iam_policy.dynamo-access-rw.arn
}
resource "aws_iam_role_policy_attachment" "basic-exec-role" {
role = aws_iam_role.assume_role_lambda.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
// Below defines all of the lambda functions and their respective environments that are zipped.
resource "aws_lambda_function" "user_handler_lambda" {
filename = "${path.module}/lambdas/output/user_handler.zip"
function_name = "user_handler_lambda"
role = aws_iam_role.assume_role_lambda.arn
handler = "user_handler.lambda_handler"
runtime = "python3.8"
timeout = 10
source_code_hash = filebase64sha256("${path.module}/lambdas/output/user_handler.zip")
}
resource "aws_lambda_function" "qwest_handler_lambda" {
filename = "${path.module}/lambdas/output/qwest_handler.zip"
function_name = "qwest_handler_lambda"
role = aws_iam_role.assume_role_lambda.arn
handler = "qwest_handler.lambda_handler"
runtime = "python3.8"
timeout = 10
source_code_hash = filebase64sha256("${path.module}/lambdas/output/qwest_handler.zip")
}
resource "aws_lambda_function" "leaderboard_handler_lambda" {
filename = "${path.module}/lambdas/output/leaderboard_handler.zip"
function_name = "leaderboard_handler_lambda"
role = aws_iam_role.assume_role_lambda.arn
handler = "leaderboard_handler.lambda_handler"
runtime = "python3.8"
timeout = 10
source_code_hash = filebase64sha256("${path.module}/lambdas/output/leaderboard_handler.zip")
}
resource "aws_lambda_function" "location_handler_lambda" {
filename = "${path.module}/lambdas/output/location_handler.zip"
function_name = "location_handler_lambda"
role = aws_iam_role.assume_role_lambda.arn
handler = "location_handler.lambda_handler"
runtime = "python3.8"
timeout = 10
source_code_hash = filebase64sha256("${path.module}/lambdas/output/location_handler.zip")
}
resource "aws_lambda_function" "confirmation_handler_lambda" {
filename = "${path.module}/lambdas/output/confirmation_handler.zip"
function_name = "confirmation_handler_lambda"
role = aws_iam_role.assume_role_lambda.arn
handler = "confirmation_handler.lambda_handler"
runtime = "python3.8"
timeout = 10
source_code_hash = filebase64sha256("${path.module}/lambdas/output/confirmation_handler.zip")
}