-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaws_lambda_function.tf
More file actions
42 lines (36 loc) · 1013 Bytes
/
aws_lambda_function.tf
File metadata and controls
42 lines (36 loc) · 1013 Bytes
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
resource "random_id" "suffix" {
byte_length = 8
}
data "aws_ecs_cluster" "cluster" {
cluster_name = var.ecs_cluster_name
}
data "aws_ecs_service" "service" {
cluster_arn = data.aws_ecs_cluster.cluster.arn
service_name = var.ecs_service_name
}
resource "aws_lambda_function" "update_ecs_service" {
filename = data.archive_file.lambda.output_path
function_name = "${var.name_prefix}-update_ecs_service-${random_id.suffix.hex}"
role = aws_iam_role.lambda_execution.arn
handler = "main.lambda_handler"
source_code_hash = data.archive_file.lambda.output_base64sha256
runtime = "python3.8"
memory_size = 128
timeout = 30
environment {
variables = {
"EcsServiceArn" = data.aws_ecs_service.service.arn
"EcsClusterName" = var.ecs_cluster_name
}
}
lifecycle {
ignore_changes = [
filename,
]
}
}
data "archive_file" "lambda" {
type = "zip"
source_dir = "${abspath(path.module)}/lambda"
output_path = "${abspath(path.module)}/.upload/slack.zip"
}