-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
57 lines (46 loc) · 1.36 KB
/
main.tf
File metadata and controls
57 lines (46 loc) · 1.36 KB
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
//resource "template_file" "this" {
// template = file("${path.module}/src/params.json")
//
// vars = {
// BUCKET_NAME = var.bucketName
// BUCKET_KEY = var.bucketKey
// COOKIE_DOMAIN = var.cookieDomain
// }
//}
resource "local_file" "params" {
// content = template_file.this.rendered
content = templatefile("${path.module}/src/params.json", {
AUTH_USER = var.authUser
AUTH_PASSWORD = var.authPassword
COOKIE_DOMAIN = var.cookieDomain
})
filename = "${path.module}/.archive/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}/.archive/main.js"
}
data "archive_file" "this" {
depends_on = [
local_file.params,
local_file.mainjs,
]
type = "zip"
output_path = "${path.module}/.archive.zip"
source_dir = "${path.module}/.archive"
}
resource "aws_lambda_function" "this" {
description = "Basic HTTP authentication module/function"
role = aws_iam_role.this.arn
runtime = "nodejs10.x"
filename = data.archive_file.this.output_path
source_code_hash = data.archive_file.this.output_base64sha256
function_name = var.name
handler = "main.handler"
timeout = var.fn_timeout
memory_size = var.fn_memory_size
publish = true
}