-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.tf
61 lines (52 loc) · 1.52 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
resource "null_resource" "install_python_dependencies" {
provisioner "local-exec" {
command = "bash ${path.module}/function/create_pkg.sh"
environment = {
runtime = "python3"
path_cwd = "${path.module}/function"
}
}
}
data "archive_file" "create_dist_pkg" {
depends_on = ["null_resource.install_python_dependencies"]
source_dir = "${path.module}/function/lambda_dist_pkg/"
output_path = "lambda.zip"
type = "zip"
}
resource "aws_security_group" "lambda" {
name = "lambda"
description = "Only empty SG"
vpc_id = module.vpc.vpc_id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "lambda"
}
}
resource "aws_lambda_function" "lambda_joiner" {
filename = "lambda.zip"
function_name = "${var.short_name}-JoinDirectoryServiceDomain"
role = aws_iam_role.lambda_joiner.arn
handler = "main.lambda_handler"
source_code_hash = "${data.archive_file.create_dist_pkg.output_base64sha256}"
runtime = "${var.runtime}"
timeout = 300
vpc_config {
subnet_ids = module.vpc.private_subnets
security_group_ids = [ aws_security_group.lambda.id ]
}
environment {
variables = {
directoryId = aws_directory_service_directory.simpleds.id
directoryOU = var.basedn
join_document = aws_ssm_document.join.name
ds_region = var.region
ldap_host = var.directory_name
proto = var.ldap_proto
}
}
}