-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
81 lines (69 loc) · 1.61 KB
/
main.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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.16.2"
}
}
}
provider "aws" {
profile = "terraform"
region = "us-east-1"
}
resource "aws_lambda_function" "test_lambda" {
s3_bucket = var.bucket_name
s3_key = var.s3_key
function_name = "api_sourcer"
role = aws_iam_role.lambda_role.arn
handler = "bootstrap"
runtime = "go1.x"
environment {
variables = {
BAR = "BAR"
FOO = "FOO"
SUPABASE_KEY = var.SUPABASE_KEY
SUPABASE_URL = var.SUPABASE_URL
X_RapidAPI_KEY = var.X_RapidAPI_KEY
}
}
}
resource "aws_lambda_function_url" "test_latest" {
function_name = aws_lambda_function.test_lambda.function_name
authorization_type = "NONE"
}
# See also the following AWS managed policy: AWSLambdaBasicExecutionRole
data "aws_iam_policy_document" "lambda_logging" {
statement {
sid = "1"
actions = [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation",
]
resources = [
"arn:aws:s3:::*",
]
}
}
resource "aws_iam_role_policy_attachment" "lambda_logs" {
role = aws_iam_role.lambda_role.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
resource "aws_iam_role" "lambda_role" {
name = "lambda_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "lambda.amazonaws.com"
}
}
]
})
}
resource "aws_s3_bucket" "exam_bot_bucket" {
bucket = var.bucket_name
force_destroy = true
}