This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.tf
81 lines (66 loc) · 1.65 KB
/
function.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
resource "aws_cloudwatch_log_group" "lambda_logs" {
name = "/aws/lambda/${local.function_name}"
retention_in_days = 7
}
resource "aws_lambda_function" "function" {
function_name = local.function_name
role = aws_iam_role.lambda_exec_role.arn
filename = local.function_path
handler = "main.handler"
runtime = "python3.8"
architectures = ["arm64"]
source_code_hash = filebase64sha256(local.function_path)
layers = [
"arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:2",
]
environment {
variables = {
TFE_HMAC = local.hmac_path
RABBIT_BASE = local.rabbit_base_path
}
}
depends_on = [
aws_cloudwatch_log_group.lambda_logs,
]
}
resource "aws_lambda_function_url" "function" {
authorization_type = "NONE"
function_name = aws_lambda_function.function.function_name
}
resource "aws_ssm_parameter" "notification_hmac" {
name = local.hmac_path
type = "SecureString"
value = "changeme"
lifecycle {
ignore_changes = [
value
]
}
}
resource "aws_ssm_parameter" "rabbitmq_public" {
for_each = {
exchange = "aws.notification"
host = "mq.srv.stwalkerster.net"
port = "5671"
username = "aws-notification"
vhost = "/"
}
name = "${local.rabbit_base_path}/${each.key}"
type = "String"
value = each.value
lifecycle {
ignore_changes = [
value
]
}
}
resource "aws_ssm_parameter" "rabbitmq_password" {
name = "${local.rabbit_base_path}/password"
type = "SecureString"
value = "changeme"
lifecycle {
ignore_changes = [
value
]
}
}