-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds new module to create some base roles Admin and readonly roles * Add the readonly role to the /ops/ path as well * Fix readonly policy name * Document base_roles module * Small refactor to simplify variables
- Loading branch information
1 parent
3a2738c
commit 95fcb44
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
data "aws_iam_policy_document" "admin_assume_role_policy" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["${var.admin_role_principal_ids}"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "admin" { | ||
name = "admin" | ||
path = "/ops/" | ||
description = "This role has full Aministrator access and is to be assumed to mange this account" | ||
assume_role_policy = "${data.aws_iam_policy_document.admin_assume_role_policy.json}" | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "admin" { | ||
role = "${aws_iam_role.admin.name}" | ||
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "admin_role_arn" { | ||
value = "${aws_iam_role.admin.arn}" | ||
description = "Admin role ARN" | ||
} | ||
|
||
output "ro_role_arn" { | ||
value = "${aws_iam_role.ro.arn}" | ||
description = "Readonly role ARN" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
data "aws_iam_policy_document" "ro_assume_role_policy" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["${var.readonly_role_principal_ids}"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "ro" { | ||
name = "readonly" | ||
path = "/ops/" | ||
description = "This role has read only access to this account" | ||
assume_role_policy = "${data.aws_iam_policy_document.ro_assume_role_policy.json}" | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "ro" { | ||
role = "${aws_iam_role.ro.name}" | ||
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "admin_role_principal_ids" { | ||
description = "List of AWS principal ids (or ARNs) that'll be allowed to assume the admin role in the ops account" | ||
type = "list" | ||
} | ||
|
||
variable "readonly_role_principal_ids" { | ||
description = "List of AWS principal ids (or ARNs) that'll be allowed to assume the readonly role in the ops account" | ||
type = "list" | ||
} |