-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.tf
79 lines (64 loc) · 1.71 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
resource "local_file" "params" {
content = templatefile("${path.module}/src/params.json", {
BUCKET_NAME = var.bucketName
BUCKET_KEY = var.bucketKey
COOKIE_DOMAIN = var.cookieDomain
})
filename = "${path.module}/src-lamda/params.json"
}
//data "local_file" "mainjs" {
// filename = "${path.module}/src/main.js"
//}
//resource "local_file" "mainjs" {
// content = data.local_file.mainjs.content
// filename = "${path.module}/src-lamda/main.js"
//}
resource "aws_cloudwatch_log_group" "this" {
name = "/aws/lambda/${var.name}"
retention_in_days = 7
}
//data "archive_file" "this" {
// depends_on = [
// local_file.params,
// local_file.mainjs,
// ]
//
// type = "zip"
// output_path = "${path.module}/src-lamda.zip"
// source_dir = "${path.module}/src-lamda"
//}
resource "null_resource" "zip" {
depends_on = [
local_file.params
]
provisioner "local-exec" {
command = <<EOT
zip -r "${path.module}/src-lamda.zip" "${path.module}/src-lamda"
EOT
}
triggers = {
uuid = uuid()
}
}
resource "aws_lambda_function" "this" {
depends_on = [
null_resource.zip
]
description = "Basic HTTP authentication module/function"
role = aws_iam_role.this.arn
runtime = "nodejs10.x"
filename = "${path.module}/src-lamda.zip"
source_code_hash = filebase64sha256("${path.module}/src-lamda/main.js")
function_name = var.name
handler = "main.handler"
timeout = var.fn_timeout
memory_size = var.fn_memory_size
publish = true
// environment {
// variables = {
// BUCKET_NAME = var.bucketName
// BUCKET_KEY = var.bucketKey
// COOKIE_DOMAIN = var.cookieDomain
// }
// }
}