-
Notifications
You must be signed in to change notification settings - Fork 3
/
subaccount_gfl.tf
56 lines (48 loc) · 1.38 KB
/
subaccount_gfl.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
module "aws-subaccount-account-init-gfl" {
source = "./aws-sub-account-init"
root_account_id = "${var.root_account_id}"
sub_account_id = "${var.sub_account_id_gfl}"
sub_account_alias = "${var.company_name}-gfl"
allowed_ips = "${var.allowed_ips}"
# Only used during bootstrap
# terraform_assume_role = "subaccount-admin"
}
resource "aws_iam_policy" "AssumeAdminRoleGflSubAccount" {
name = "AssumeAdminRoleGflSubAccount"
description = "Allow to assume any role in the gfl subaccounts"
path = "/custom/"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": ${
jsonencode(
formatlist(
"arn:aws:iam::%s:role/*",
list(var.sub_account_id_gfl)
)
)
}
}
}
EOF
}
resource "aws_iam_group" "gfl_admin_users" {
name = "gfl_admin_users"
}
resource "aws_iam_group_membership" "gfl_admin_users" {
name = "gfl_admin_users_group_membership"
group = "${aws_iam_group.gfl_admin_users.name}"
users = [
"${module.graciafdez_aws_dev_keytwine_com.name}",
"${module.hector_rivas_aws_admin_keytwine_com.name}",
]
}
resource "aws_iam_group_policy_attachment" "gfl_admin_users_AssumeAdminRoleGflSubAccount" {
group = "${aws_iam_group.gfl_admin_users.name}"
policy_arn = "${aws_iam_policy.AssumeAdminRoleGflSubAccount.arn}"
}