-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlambda.tf
More file actions
39 lines (30 loc) · 1.16 KB
/
lambda.tf
File metadata and controls
39 lines (30 loc) · 1.16 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
data "archive_file" "ec2_auto_start_zip" {
type = "zip"
source_file = "${path.module}/ec2-auto-start.py"
output_path = "${path.module}/ec2-auto-start.zip"
}
data "archive_file" "ec2_auto_stop_zip" {
type = "zip"
source_file = "${path.module}/ec2-auto-stop.py"
output_path = "${path.module}/ec2-auto-stop.zip"
}
resource "aws_lambda_function" "ec2_auto_start" {
function_name = "EC2AutoStart"
handler = "ec2-auto-start.lambda_handler"
role = aws_iam_role.lambda_role.arn
runtime = "python3.12"
filename = data.archive_file.ec2_auto_start_zip.output_path
source_code_hash = data.archive_file.ec2_auto_start_zip.output_base64sha256
timeout = 60
depends_on = [aws_iam_policy.lambda_policy]
}
resource "aws_lambda_function" "ec2_auto_stop" {
function_name = "EC2AutoStop"
handler = "ec2-auto-stop.lambda_handler"
role = aws_iam_role.lambda_role.arn
runtime = "python3.12"
filename = data.archive_file.ec2_auto_stop_zip.output_path
source_code_hash = data.archive_file.ec2_auto_stop_zip.output_base64sha256
timeout = 60
depends_on = [aws_iam_policy.lambda_policy]
}