-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.tf
43 lines (36 loc) · 1018 Bytes
/
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
terraform {
required_version = "~> 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
data "aws_iam_policy_document" "assume_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
resource "aws_iam_role" "role" {
assume_role_policy = data.aws_iam_policy_document.assume_role.json
name = var.name
}
resource "aws_iam_role_policy_attachment" "basic" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
role = aws_iam_role.role.name
}
resource "aws_iam_role_policy_attachment" "additional" {
count = length(var.attachments)
policy_arn = element(var.attachments, count.index)
role = aws_iam_role.role.name
}
resource "aws_iam_role_policy" "inline" {
count = length(var.inline_policies)
policy = element(var.inline_policies, count.index)
role = aws_iam_role.role.id
}