-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
44 lines (35 loc) · 1.19 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
// main tf file for Cidr-house-rules-role
data "aws_iam_policy_document" "cidr_house_assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${var.cidr_house_rules_account_number}:role/cidr-house-rules-${var.serverless_dev_stage}-${var.serverless_region}-lambdaRole",
"arn:aws:iam::${var.cidr_house_rules_account_number}:role/cidr-house-rules-${var.serverless_prod_stage}-${var.serverless_region}-lambdaRole",
]
}
}
}
data "aws_iam_policy_document" "cidr_house_policy" {
statement {
effect = "Allow"
actions = ["ec2:Describe*", "elasticloadbalancing:Describe*"]
resources = ["*"]
}
}
resource "aws_iam_role" "cidr_house_role" {
name = "role_cidr_house"
path = "/"
assume_role_policy = "${data.aws_iam_policy_document.cidr_house_assume_role.json}"
}
resource "aws_iam_role_policy" "role_cidr_house_policy" {
name = "cidr_house_policy"
role = "${aws_iam_role.cidr_house_role.id}"
policy = "${data.aws_iam_policy_document.cidr_house_policy.json}"
}