-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(permissions): add optional real-time detection to the AWS onboarding templates #12471
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
ae1592d
0a39c00
29102e7
56d33fe
b5a23a2
580a043
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,9 @@ This Terraform configuration creates the necessary IAM role and policies to allo | |
| - `enable_s3_integration` (optional): Enable S3 integration for storing scan reports (default: false) | ||
| - `s3_integration_bucket_name` (conditional): S3 bucket name for reports (required if `enable_s3_integration` is true) | ||
| - `s3_integration_bucket_account_id` (conditional): S3 bucket owner account ID (required if `enable_s3_integration` is true) | ||
| - `enable_realtime_detection` (optional): Forward the tracked CloudTrail management events to Prowler Cloud through an EventBridge API destination (default: false) | ||
| - `prowler_webhook_url` (conditional): Prowler Cloud endpoint that receives the events (required if `enable_realtime_detection` is true) | ||
| - `prowler_api_key` (conditional): Prowler Cloud API key used to authenticate the events (required if `enable_realtime_detection` is true) | ||
|
|
||
| ### Usage Examples | ||
|
|
||
|
|
@@ -42,6 +45,17 @@ terraform apply \ | |
| -var="s3_integration_bucket_account_id=123456789012" | ||
| ``` | ||
|
|
||
| #### With real-time detection enabled | ||
| ```bash | ||
| terraform apply \ | ||
| -var="external_id=your-external-id-here" \ | ||
| -var="enable_realtime_detection=true" \ | ||
| -var="prowler_webhook_url=https://api.prowler.com/api/v1/realtime/events" \ | ||
| -var="prowler_api_key=your-prowler-api-key-here" | ||
| ``` | ||
|
|
||
| > **Note:** the EventBridge rule is regional. It forwards only the events delivered to the default event bus of the region Terraform deploys to (`us-east-1` by default, see `versions.tf`). IAM events are global and always land in `us-east-1`, but regional services (EC2 security groups, RDS, per-region Config and GuardDuty) are only covered in that region. Deploy the module in every region you want covered. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 4 \
'provider\s+"aws"|region\s*=|module\s+"realtime_detection"|enable_realtime_detection' \
permissions/templates/terraform/versions.tf \
permissions/templates/terraform/main.tf \
permissions/templates/terraform/README.mdRepository: prowler-cloud/prowler Length of output: 4379 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Terraform template files ---'
ast-grep outline permissions/templates/terraform/versions.tf
ast-grep outline permissions/templates/terraform/variables.tf
ast-grep outline permissions/templates/terraform/main.tf
printf '%s\n' '--- Relevant source ---'
cat -n permissions/templates/terraform/versions.tf
cat -n permissions/templates/terraform/variables.tf
sed -n '1,180p' permissions/templates/terraform/main.tf
printf '%s\n' '--- README region and deployment guidance ---'
rg -n -C 8 'region|Region|EventBridge|default event bus|Deploy the module' permissions/templates/terraform/README.md
printf '%s\n' '--- Provider and region references ---'
rg -n -C 3 'provider\s+"aws"|region\s*=|AWS_REGION|aws_region|alias\s*=' permissions/templates/terraformRepository: prowler-cloud/prowler Length of output: 13733 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Real-time detection module ---'
ast-grep outline permissions/templates/terraform/realtime-detection
for f in permissions/templates/terraform/realtime-detection/*.tf; do
printf '\n--- %s ---\n' "$f"
cat -n "$f"
done
printf '%s\n' '--- Read-only structural verifier ---'
python3 - <<'PY'
from pathlib import Path
import re
root = Path("permissions/templates/terraform")
provider = (root / "versions.tf").read_text()
variables = (root / "variables.tf").read_text()
readme = (root / "README.md").read_text()
module = (root / "realtime-detection" / "main.tf").read_text()
provider_region = re.search(r'provider\s+"aws"\s*\{(?P<body>.*?)\n\}', provider, re.S)
assert provider_region, "AWS provider block not found"
body = provider_region.group("body")
print("provider_region_assignment:", re.findall(r'^\s*region\s*=\s*(.+)$', body, re.M))
print("has_region_variable:", bool(re.search(r'variable\s+"region"\s*\{', variables)))
print("readme_says_deploy_each_region:", "Deploy the module in every region you want covered." in readme)
print("eventbridge_rule_resource_count:", len(re.findall(r'resource\s+"aws_cloudwatch_event_rule"', module)))
print("event_pattern_mentions_regions:", sorted(set(re.findall(r'"aws\.[^"]+"', module))))
print("uses_current_provider_region:", "data.aws_region.current.name" in module)
PYRepository: prowler-cloud/prowler Length of output: 7842 Make multi-Region deployment configurable.
🤖 Prompt for AI Agents |
||
|
|
||
| #### Using terraform.tfvars file (Recommended) | ||
| ```bash | ||
| cp terraform.tfvars.example terraform.tfvars | ||
|
|
@@ -60,5 +74,8 @@ After successful deployment, you'll get: | |
| - `prowler_role_arn`: The ARN of the created IAM role (use this in Prowler App) | ||
| - `prowler_role_name`: The name of the IAM role | ||
| - `s3_integration_enabled`: Whether S3 integration is enabled | ||
| - `realtime_detection_enabled`: Whether real-time detection is enabled | ||
| - `prowler_realtime_rule_arn`: ARN of the EventBridge rule (null if real-time detection is disabled) | ||
| - `prowler_realtime_api_destination_arn`: ARN of the EventBridge API destination (null if real-time detection is disabled) | ||
|
|
||
| > **Note:** Terraform will use the AWS credentials of your default profile or AWS_PROFILE environment variable. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| data "aws_partition" "current" {} | ||
| data "aws_caller_identity" "current" {} | ||
| data "aws_region" "current" {} |
Uh oh!
There was an error while loading. Please reload this page.