Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding permissions in AWS trust relationship module #54

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/services/trust-relationship/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
This module will deploy a Trust Relationship (IAM Role) into a single AWS account, or each account within an AWS Organization.

The following resources will be created in each instrumented account:
- An IAM Role and associated IAM Policiy (`arn:aws:iam::aws:policy/SecurityAudit`) to grant Sysdig read only permissions to secure you AWS Account.
- An IAM Role and associated IAM Policies mentioned below to grant Sysdig read only permissions to secure you AWS Account:
- `arn:aws:iam::aws:policy/SecurityAudit`
- a custom policy (`custom_resources_policy`)
- An Access Policy attached to this role using a Sysdig provided `ExternalId`.

If instrumenting an AWS Organization, an `aws_cloudformation_stack_set` will be created in the Management Account.
Expand Down Expand Up @@ -34,6 +36,7 @@ No modules.
| [aws_cloudformation_stack_set_instance.stackset_instance](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set_instance) | resource |
| [aws_iam_role.cspm_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_organizations_organization.org](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source |
| [aws_iam_policy_document.custom_resources_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

## Inputs

Expand Down
74 changes: 74 additions & 0 deletions modules/services/trust-relationship/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,58 @@ resource "aws_iam_role" "cspm_role" {
}
EOF
managed_policy_arns = ["arn:aws:iam::aws:policy/SecurityAudit"]
inline_policy {
name = var.role_name
policy = data.aws_iam_policy_document.custom_resources_policy.json
}
}

# Custom IAM Policy Document used by trust-relationship role
data "aws_iam_policy_document" "custom_resources_policy" {

statement {
sid = "DescribeEFSAccessPoints"

effect = "Allow"

actions = [
"elasticfilesystem:DescribeAccessPoints",
]

resources = [
"*",
]
}

statement {
sid = "ListWafRegionalRulesAndRuleGroups"

effect = "Allow"

actions = [
"waf-regional:ListRules",
"waf-regional:ListRuleGroups",
]

resources = [
"arn:aws:waf-regional:*:*:rule/*",
"arn:aws:waf-regional:*:*:rulegroup/*"
]
}

statement {
sid = "AccessAccountContactInfo"

effect = "Allow"

actions = [
"account:GetContactInformation",
]

resources = [
"*",
]
}
}

#----------------------------------------------------------
Expand Down Expand Up @@ -77,6 +129,28 @@ Resources:
sts:ExternalId: ${var.external_id}
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/SecurityAudit"
Policies:
- PolicyName: ${var.role_name}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: "DescribeEFSAccessPoints"
Effect: "Allow"
Action: "elasticfilesystem:DescribeAccessPoints"
Resource: "*"
- Sid: "ListWafRegionalRulesAndRuleGroups"
Effect: "Allow"
Action:
- "waf-regional:ListRules"
- "waf-regional:ListRuleGroups"
Resource:
- "arn:aws:waf-regional:*:*:rule/*"
- "arn:aws:waf-regional:*:*:rulegroup/*"
- Sid: "AccessAccountContactInfo"
Effect: "Allow"
Action:
- "account:GetContactInformation"
Resource: "*"
TEMPLATE
}

Expand Down
Loading