Skip to content

Commit 3c05ab1

Browse files
authored
Introducing account_org_paths to limit the reachable accounts by OU path (#152)
This PR introduces a new optional account_org_paths to the scanner role. This new variable can be used to enforce that the scanner can only reach for roles in the specified organisational unit paths. Now that the account_roles is optional and defaults to a wildcard allowing to assume roles from any account, to limit the scope of the scanner role, without losing the convenience of specifying a account wildcard.
1 parent a4f2766 commit 3c05ab1

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## Version TBD
3+
## Version 0.11.5 - 2024-10-16
44

5-
- Scanner role delegations based on a account_id wildcard by default
5+
- Scanner role delegations based on a account_id wildcard by default: `account_roles` variable is now optional and defaults to allowing all accounts
6+
- Scanner role delegations can be limited to a specific list of organizational unit paths via the `account_org_paths` variable
67

78
## Version 0.11.4
89

modules/agentless-scanner-role/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ No modules.
3939

4040
| Name | Description | Type | Default | Required |
4141
|------|-------------|------|---------|:--------:|
42+
| <a name="input_account_org_paths"></a> [account\_org\_paths](#input\_account\_org\_paths) | List of AWS Organizations organizational unit (OU) paths in which the agentless scanner is allowed to assume role (default allows all) | `list(string)` | <pre>[<br> "*"<br>]</pre> | no |
4243
| <a name="input_account_roles"></a> [account\_roles](#input\_account\_roles) | List of cross accounts roles ARN that the Datadog agentless scanner can assume - make sure to respect the same naming convention as the agentless scanner role. | `list(string)` | <pre>[<br> "arn:*:iam::*:role/DatadogAgentlessScannerDelegateRole"<br>]</pre> | no |
4344
| <a name="input_api_key_secret_arns"></a> [api\_key\_secret\_arns](#input\_api\_key\_secret\_arns) | List of ARNs of the secrets holding the Datadog API keys | `list(string)` | n/a | yes |
4445
| <a name="input_api_key_secret_kms_key_arns"></a> [api\_key\_secret\_kms\_key\_arns](#input\_api\_key\_secret\_kms\_key\_arns) | List of ARNs of the KMS keys encrypting the secrets | `list(string)` | `[]` | no |

modules/agentless-scanner-role/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ data "aws_iam_policy_document" "scanner_policy_document" {
5353
resources = var.account_roles
5454
}
5555

56+
# Denying the ability to assume roles outside of the specified OU paths.
57+
# Variable account_org_paths defaults to ["*"] which allows the role to be
58+
# assumed from any OU
59+
statement {
60+
sid = "EC2DenyAssumeRoleOutsideOUs"
61+
actions = ["sts:AssumeRole"]
62+
effect = "Deny"
63+
resources = ["arn:aws:iam::*:*"]
64+
condition {
65+
test = "ForAllValues:StringNotLike"
66+
variable = "aws:ResourceOrgPaths"
67+
values = var.account_org_paths
68+
}
69+
}
70+
5671
statement {
5772
sid = "ReadSecret"
5873
actions = ["secretsmanager:GetSecretValue"]

modules/agentless-scanner-role/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ variable "account_roles" {
2828
default = ["arn:*:iam::*:role/DatadogAgentlessScannerDelegateRole"]
2929
}
3030

31+
variable "account_org_paths" {
32+
description = "List of AWS Organizations organizational unit (OU) paths in which the agentless scanner is allowed to assume role (default allows all)"
33+
type = list(string)
34+
default = ["*"]
35+
}
36+
3137
variable "api_key_secret_arns" {
3238
description = "List of ARNs of the secrets holding the Datadog API keys"
3339
type = list(string)

0 commit comments

Comments
 (0)