-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.tf
More file actions
54 lines (46 loc) · 1.46 KB
/
lambda.tf
File metadata and controls
54 lines (46 loc) · 1.46 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
data "aws_iam_role" "lambda_exec_role" {
name = "tc-infra-id-lambda-exec-role"
}
resource "aws_security_group" "id_lambda" {
name = "tc-id-lambda-sg"
description = "Security group for Lambda ID function"
vpc_id = data.aws_vpc.tc_lambda_vpc.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = var.tags
}
resource "aws_lambda_function" "id_lambda" {
function_name = "lambda-identification-auth"
depends_on = []
role = data.aws_iam_role.lambda_exec_role.arn
handler = "tech.buildrun.lambda.Handler::handleRequest"
runtime = "java17"
timeout = 20
# Usa o caminho passado via variável
filename = var.lambda_jar_path
source_code_hash = filebase64sha256(var.lambda_jar_path)
environment {
variables = {
DB_URL = local.jdbc_url
DB_USER = var.db_user
DB_PASSWORD = var.db_password
JWT_SECRET = var.jwt_secret
}
}
vpc_config {
subnet_ids = data.aws_subnets.tc_lambda_subnets.ids
security_group_ids = [aws_security_group.id_lambda.id]
}
tags = var.tags
}
resource "aws_lambda_permission" "apigw_invoke_lambda" {
statement_id = "AllowAPIGatewayInvoke"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.id_lambda.function_name
principal = "apigateway.amazonaws.com"
source_arn = "${data.aws_apigatewayv2_api.tc_api.execution_arn}/*/*"
}