Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
228 additions
and
4 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
39 changes: 39 additions & 0 deletions
39
...malert_cli/_infrastructure/modules/tf_cloudwatch_events/cross_account/README.md
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,39 @@ | ||
# StreamAlert CloudWatch Events Cross Account Terraform Module | ||
Configure the necessary resources to allow for cross account CloudWatch Events via EventBridge Events Bus | ||
|
||
## Components | ||
* Configures CloudWatch Event Permissions to allow external accounts or organizations to send events to the main account | ||
|
||
## Example | ||
```hcl | ||
module "cloudwatch_events_cross_account" { | ||
source = "./modules/tf_cloudwatch_events/cross_account" | ||
accounts = ["123456789012"] | ||
organizations = ["o-aabbccddee"] | ||
region = "us-east-1" | ||
} | ||
``` | ||
|
||
## Inputs | ||
<table> | ||
<tr> | ||
<th>Property</th> | ||
<th>Description</th> | ||
<th>Default (None=Required)</th> | ||
</tr> | ||
<tr> | ||
<td>accounts</td> | ||
<td>AWS Account IDs for which to enable cross account CloudWatch Events</td> | ||
<td>None</td> | ||
</tr> | ||
<tr> | ||
<td>organizations</td> | ||
<td>AWS Organization IDs for which to enable cross account CloudWatch Events</td> | ||
<td>None</td> | ||
</tr> | ||
<tr> | ||
<td>region</td> | ||
<td>AWS region in which this permission is being added</td> | ||
<td>None</td> | ||
</tr> | ||
</table> |
19 changes: 19 additions & 0 deletions
19
streamalert_cli/_infrastructure/modules/tf_cloudwatch_events/cross_account/main.tf
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,19 @@ | ||
// CloudWatch Event Permission for Individual AWS Accounts | ||
resource "aws_cloudwatch_event_permission" "account_access" { | ||
count = length(var.accounts) | ||
principal = element(var.accounts, count.index) | ||
statement_id = "account_${element(var.accounts, count.index)}_${var.region}" | ||
} | ||
|
||
// CloudWatch Event Permission for AWS Orgs | ||
resource "aws_cloudwatch_event_permission" "organization_access" { | ||
count = length(var.organizations) | ||
principal = "*" | ||
statement_id = "organization_${element(var.organizations, count.index)}_${var.region}" | ||
|
||
condition { | ||
key = "aws:PrincipalOrgID" | ||
type = "StringEquals" | ||
value = element(var.organizations, count.index) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
streamalert_cli/_infrastructure/modules/tf_cloudwatch_events/cross_account/variables.tf
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,11 @@ | ||
variable "accounts" { | ||
type = list(string) | ||
} | ||
|
||
variable "organizations" { | ||
type = list(string) | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
} |
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
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