-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.tf
51 lines (45 loc) · 1.18 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
# Create AWS Lambda Function from ECR Image
resource "aws_lambda_function" "ollama" {
depends_on = [
aws_ecr_repository.ecr,
null_resource.build,
aws_iam_role.lambda
]
function_name = var.project_name
architectures = [
"arm64",
]
package_type = "Image"
image_uri = "${aws_ecr_repository.ecr.repository_url}:latest"
role = aws_iam_role.lambda.arn
memory_size = 8192
timeout = 600
environment {
variables = {
RUST_LOG = "debug"
PORT = "8080"
HOME = "/mnt/ollama"
AWS_LWA_INVOKE_MODE = "response_stream"
}
}
}
# Update Lambda Image to latest with Lambda API
resource "null_resource" "post_deployment" {
depends_on = [
aws_lambda_function.ollama,
null_resource.build
]
triggers = {
build_number = timestamp()
}
provisioner "local-exec" {
interpreter = [
"/bin/sh",
"-c"
]
command = <<-COMMAND
# Update Lambda Image to latest with Lambda API
aws lambda update-function-code --function-name ${aws_lambda_function.ollama.function_name} --image-uri ${aws_ecr_repository.ecr.repository_url}:latest
COMMAND
}
}