-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda.txt
More file actions
38 lines (31 loc) · 1.01 KB
/
lambda.txt
File metadata and controls
38 lines (31 loc) · 1.01 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
provider "aws" {
region = "ap-south-1"
}
# IAM Role for Lambda Execution
resource "aws_iam_role" "lambda_role" {
name = "lambda-execution-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "lambda.amazonaws.com"
}
}]
})
}
resource "aws_iam_role_policy_attachment" "lambda_policy" {
role = aws_iam_role.lambda_role.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
# Lambda Function Without S3
resource "aws_lambda_function" "my_lambda" {
function_name = "my-lambda-function"
role = aws_iam_role.lambda_role.arn
handler = "index.handler"
runtime = "nodejs18.x"
timeout = 10
filename = "/workspaces/web-app-demo/apps/lambda/lambda.zip" # Reference the local file
source_code_hash = filebase64sha256("/workspaces/web-app-demo/apps/lambda/lambda.zip") # Ensures updates trigger redeployment
}