-
Notifications
You must be signed in to change notification settings - Fork 296
/
Copy pathmain.tf
46 lines (40 loc) · 1.06 KB
/
main.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
terraform {
required_version = ">= 1.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
archive = {
source = "hashicorp/archive"
version = "~> 2.4"
}
}
}
provider "aws" {
region = "us-west-2"
}
data "aws_iam_policy_document" "lambda_assume_role_policy" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
resource "aws_iam_role" "lambda_role" {
name = "lambda-lambda-role"
assume_role_policy = data.aws_iam_policy_document.lambda_assume_role_policy.json
}
module "lambda_function" {
source = "./modules/lambda_function"
for_each = { for index, fn in var.lambda_functions : fn.name => fn }
name = each.value.name
lambda_role_arn = aws_iam_role.lambda_role.arn
source_file = "${path.root}/${each.value.source_file}"
zip_file_name = each.value.zip_file_name
timeout = each.value.timeout
runtime = each.value.runtime
}