forked from joshuamkite/terraform-aws-ssh-bastion-service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiam_child.tf
57 lines (47 loc) · 1.34 KB
/
iam_child.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
52
53
54
55
56
57
#role in child account
resource "aws_iam_role" "bastion_service_assume_role" {
name = "${module.label.id}-role"
count = "${local.assume_role_yes}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow"
}
]
}
EOF
}
#Instance profile
resource "aws_iam_instance_profile" "bastion_service_assume_role_profile" {
name = "${module.label.id}-profile"
count = "${local.assume_role_yes}"
role = "${aws_iam_role.bastion_service_assume_role.name}"
}
data "aws_iam_policy_document" "bastion_service_assume_role_in_parent" {
count = "${local.assume_role_yes}"
statement {
effect = "Allow"
actions = [
"sts:AssumeRole",
]
resources = [
"${var.assume_role_arn}",
]
}
}
resource "aws_iam_policy" "bastion_service_assume_role_in_parent" {
count = "${local.assume_role_yes}"
name = "${module.label.id}-policy"
policy = "${data.aws_iam_policy_document.bastion_service_assume_role_in_parent.json}"
}
resource "aws_iam_role_policy_attachment" "bastion_service_assume_role" {
role = "${aws_iam_role.bastion_service_assume_role.name}"
count = "${local.assume_role_yes}"
policy_arn = "${aws_iam_policy.bastion_service_assume_role_in_parent.arn}"
}