Skip to content

Commit 5e877d9

Browse files
authored
Merge pull request #28 from SumoLogic/sumo-provider-v2.28
Upgrade Sumo and AWS provider TF
2 parents b7722c6 + 4f8e054 commit 5e877d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1589
-179
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
18+
# Terraform files
19+
*.terraform
20+
*.tfstate
21+
*.tfstate.backup
22+
*.terraform.lock.hcl
23+
.idea

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The modules configure/create the following resources:
3030
}
3131
sumologic = {
3232
source = "sumologic/sumologic"
33-
version = "~> 2.1.0"
33+
version = ">= 2.28.3, < 3.0.0"
3434
}
3535
jira = {
3636
source = "fourplusone/jira"

aws/cloudtrail/README.md

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,67 @@ This module is used to create AWS and Sumo Logic resource to collect CloudTrail
1212

1313
| Name | Version |
1414
|------|---------|
15-
| terraform | >= 0.13.0 |
16-
| aws | >= 3.42.0 |
17-
| random | >=3.1.0 |
18-
| sumologic | >= 2.9.0 |
19-
| time | >=0.7.1 |
15+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
16+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.16.2, < 6.0.0 |
17+
| <a name="requirement_random"></a> [random](#requirement\_random) | >=3.1.0 |
18+
| <a name="requirement_sumologic"></a> [sumologic](#requirement\_sumologic) | >= 2.28.3, < 3.0.0 |
19+
| <a name="requirement_time"></a> [time](#requirement\_time) | >=0.7.1 |
2020

2121
## Providers
2222

2323
| Name | Version |
2424
|------|---------|
25-
| aws | >= 3.42.0 |
26-
| random | >=3.1.0 |
27-
| sumologic | >= 2.9.0 |
28-
| time | >=0.7.1 |
25+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.16.2, < 6.0.0 |
26+
| <a name="provider_random"></a> [random](#provider\_random) | >=3.1.0 |
27+
| <a name="provider_sumologic"></a> [sumologic](#provider\_sumologic) | >= 2.28.3, < 3.0.0 |
28+
| <a name="provider_time"></a> [time](#provider\_time) | >=0.7.1 |
29+
30+
## Modules
31+
32+
No modules.
33+
34+
## Resources
35+
36+
| Name | Type |
37+
|------|------|
38+
| [aws_cloudtrail.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail) | resource |
39+
| [aws_iam_policy.iam_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
40+
| [aws_iam_role.source_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
41+
| [aws_s3_bucket.s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
42+
| [aws_s3_bucket_notification.bucket_notification](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_notification) | resource |
43+
| [aws_s3_bucket_policy.s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
44+
| [aws_sns_topic.sns_topic](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
45+
| [aws_sns_topic_subscription.subscription](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription) | resource |
46+
| [random_string.aws_random](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
47+
| [sumologic_cloudtrail_source.source](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/cloudtrail_source) | resource |
48+
| [sumologic_collector.collector](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/collector) | resource |
49+
| [time_sleep.wait_for_seconds](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
50+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
51+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
52+
| [sumologic_caller_identity.current](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/data-sources/caller_identity) | data source |
2953

3054
## Inputs
3155

3256
| Name | Description | Type | Default | Required |
3357
|------|-------------|------|---------|:--------:|
34-
| cloudtrail\_details | Provide details for the AWS CloudTrail. If not provided, then defaults will be used. | <pre>object({<br> name = string<br> is_multi_region_trail = bool<br> is_organization_trail = bool<br> include_global_service_events = bool<br> })</pre> | <pre>{<br> "include_global_service_events": false,<br> "is_multi_region_trail": false,<br> "is_organization_trail": false,<br> "name": "SumoLogic-Terraform-CloudTrail-random-id"<br>}</pre> | no |
35-
| collector\_details | Provide details for the Sumo Logic collector. If not provided, then defaults will be used. | <pre>object({<br> collector_name = string<br> description = string<br> fields = map(string)<br> })</pre> | <pre>{<br> "collector_name": "SumoLogic CloudTrail Collector <Random ID>",<br> "description": "This collector is created using Sumo Logic terraform AWS cloudtrail module to collect AWS cloudtrail logs.",<br> "fields": {}<br>}</pre> | no |
36-
| create\_collector | Provide "true" if you would like to create the Sumo Logic Collector. | `bool` | n/a | yes |
37-
| create\_trail | Provide "true" if you would like to create the AWS CloudTrail. If the bucket is created by the module, module by default creates the AWS cloudtrail. | `bool` | n/a | yes |
38-
| source\_details | Provide details for the Sumo Logic CloudTrail source. If not provided, then defaults will be used. | <pre>object({<br> source_name = string<br> source_category = string<br> collector_id = string<br> description = string<br> bucket_details = object({<br> create_bucket = bool<br> bucket_name = string<br> path_expression = string<br> force_destroy_bucket = bool<br> })<br> paused = bool<br> scan_interval = string<br> sumo_account_id = number<br> cutoff_relative_time = string<br> fields = map(string)<br> iam_details = object({<br> create_iam_role = bool<br> iam_role_arn = string<br> })<br> sns_topic_details = object({<br> create_sns_topic = bool<br> sns_topic_arn = string<br> })<br> })</pre> | <pre>{<br> "bucket_details": {<br> "bucket_name": "cloudtrail-logs-random-id",<br> "create_bucket": true,<br> "force_destroy_bucket": true,<br> "path_expression": "AWSLogs/<ACCOUNT-ID>/CloudTrail/<REGION-NAME>/*"<br> },<br> "collector_id": "",<br> "cutoff_relative_time": "-1d",<br> "description": "This source is created using Sumo Logic terraform AWS cloudtrail module to collect AWS cloudtrail logs.",<br> "fields": {},<br> "iam_details": {<br> "create_iam_role": true,<br> "iam_role_arn": null<br> },<br> "paused": false,<br> "scan_interval": 300000,<br> "sns_topic_details": {<br> "create_sns_topic": true,<br> "sns_topic_arn": null<br> },<br> "source_category": "Labs/aws/cloudtrail",<br> "source_name": "CloudTrail Source",<br> "sumo_account_id": 926226587429<br>}</pre> | no |
39-
| sumologic\_organization\_id | Appears on the Account Overview page that displays information about your Sumo Logic organization. Used for IAM Role in Sumo Logic AWS Sources. | `string` | n/a | yes |
40-
| wait\_for\_seconds | wait\_for\_seconds is used to delay sumo logic source creation. This helps persisting IAM role in AWS system.<br> Default value is 180 seconds.<br> If the AWS IAM role is created outside the module, the value can be decreased to 1 second. | `number` | `180` | no |
58+
| <a name="input_cloudtrail_details"></a> [cloudtrail\_details](#input\_cloudtrail\_details) | Provide details for the AWS CloudTrail. If not provided, then defaults will be used. | <pre>object({<br> name = string<br> is_multi_region_trail = bool<br> is_organization_trail = bool<br> include_global_service_events = bool<br> })</pre> | <pre>{<br> "include_global_service_events": false,<br> "is_multi_region_trail": false,<br> "is_organization_trail": false,<br> "name": "SumoLogic-Terraform-CloudTrail-random-id"<br>}</pre> | no |
59+
| <a name="input_collector_details"></a> [collector\_details](#input\_collector\_details) | Provide details for the Sumo Logic collector. If not provided, then defaults will be used. | <pre>object({<br> collector_name = string<br> description = string<br> fields = map(string)<br> })</pre> | <pre>{<br> "collector_name": "SumoLogic CloudTrail Collector <Random ID>",<br> "description": "This collector is created using Sumo Logic terraform AWS cloudtrail module to collect AWS cloudtrail logs.",<br> "fields": {}<br>}</pre> | no |
60+
| <a name="input_create_collector"></a> [create\_collector](#input\_create\_collector) | Provide "true" if you would like to create the Sumo Logic Collector. | `bool` | n/a | yes |
61+
| <a name="input_create_trail"></a> [create\_trail](#input\_create\_trail) | Provide "true" if you would like to create the AWS CloudTrail. If the bucket is created by the module, module by default creates the AWS cloudtrail. | `bool` | n/a | yes |
62+
| <a name="input_source_details"></a> [source\_details](#input\_source\_details) | Provide details for the Sumo Logic CloudTrail source. If not provided, then defaults will be used. | <pre>object({<br> source_name = string<br> source_category = string<br> collector_id = string<br> description = string<br> bucket_details = object({<br> create_bucket = bool<br> bucket_name = string<br> path_expression = string<br> force_destroy_bucket = bool<br> })<br> paused = bool<br> scan_interval = string<br> sumo_account_id = number<br> cutoff_relative_time = string<br> fields = map(string)<br> iam_details = object({<br> create_iam_role = bool<br> iam_role_arn = string<br> })<br> sns_topic_details = object({<br> create_sns_topic = bool<br> sns_topic_arn = string<br> })<br> })</pre> | <pre>{<br> "bucket_details": {<br> "bucket_name": "cloudtrail-logs-random-id",<br> "create_bucket": true,<br> "force_destroy_bucket": true,<br> "path_expression": "AWSLogs/<ACCOUNT-ID>/CloudTrail/<REGION-NAME>/*"<br> },<br> "collector_id": "",<br> "cutoff_relative_time": "-1d",<br> "description": "This source is created using Sumo Logic terraform AWS cloudtrail module to collect AWS cloudtrail logs.",<br> "fields": {},<br> "iam_details": {<br> "create_iam_role": true,<br> "iam_role_arn": null<br> },<br> "paused": false,<br> "scan_interval": 300000,<br> "sns_topic_details": {<br> "create_sns_topic": true,<br> "sns_topic_arn": null<br> },<br> "source_category": "Labs/aws/cloudtrail",<br> "source_name": "CloudTrail Source",<br> "sumo_account_id": 926226587429<br>}</pre> | no |
63+
| <a name="input_sumologic_organization_id"></a> [sumologic\_organization\_id](#input\_sumologic\_organization\_id) | Appears on the Account Overview page that displays information about your Sumo Logic organization. Used for IAM Role in Sumo Logic AWS Sources. | `string` | n/a | yes |
64+
| <a name="input_wait_for_seconds"></a> [wait\_for\_seconds](#input\_wait\_for\_seconds) | wait\_for\_seconds is used to delay sumo logic source creation. This helps persisting IAM role in AWS system.<br> Default value is 180 seconds.<br> If the AWS IAM role is created outside the module, the value can be decreased to 1 second. | `number` | `180` | no |
4165

4266
## Outputs
4367

4468
| Name | Description |
4569
|------|-------------|
46-
| aws\_cloudtrail | AWS Trail created to send CloudTrail logs to AWS S3 bucket. |
47-
| aws\_iam\_role | AWS IAM role with permission to allow Sumo Logic to read logs from S3 Bucket. |
48-
| aws\_s3\_bucket | AWS S3 Bucket name created to Store the CloudTrail logs. |
49-
| aws\_s3\_bucket\_notification | AWS S3 Bucket Notification attached to the AWS S3 Bucket |
50-
| aws\_sns\_subscription | AWS SNS subscription to Sumo Logic AWS CloudTrail source. |
51-
| aws\_sns\_topic | AWS SNS topic attached to the AWS S3 bucket. |
52-
| random\_string | Random String value created. |
53-
| sumologic\_collector | Sumo Logic hosted collector. |
54-
| sumologic\_source | Sumo Logic AWS CloudTrail source. |
70+
| <a name="output_aws_cloudtrail"></a> [aws\_cloudtrail](#output\_aws\_cloudtrail) | AWS Trail created to send CloudTrail logs to AWS S3 bucket. |
71+
| <a name="output_aws_iam_role"></a> [aws\_iam\_role](#output\_aws\_iam\_role) | AWS IAM role with permission to allow Sumo Logic to read logs from S3 Bucket. |
72+
| <a name="output_aws_s3_bucket"></a> [aws\_s3\_bucket](#output\_aws\_s3\_bucket) | AWS S3 Bucket name created to Store the CloudTrail logs. |
73+
| <a name="output_aws_s3_bucket_notification"></a> [aws\_s3\_bucket\_notification](#output\_aws\_s3\_bucket\_notification) | AWS S3 Bucket Notification attached to the AWS S3 Bucket |
74+
| <a name="output_aws_sns_subscription"></a> [aws\_sns\_subscription](#output\_aws\_sns\_subscription) | AWS SNS subscription to Sumo Logic AWS CloudTrail source. |
75+
| <a name="output_aws_sns_topic"></a> [aws\_sns\_topic](#output\_aws\_sns\_topic) | AWS SNS topic attached to the AWS S3 bucket. |
76+
| <a name="output_random_string"></a> [random\_string](#output\_random\_string) | Random String value created. |
77+
| <a name="output_sumologic_collector"></a> [sumologic\_collector](#output\_sumologic\_collector) | Sumo Logic hosted collector. |
78+
| <a name="output_sumologic_source"></a> [sumologic\_source](#output\_sumologic\_source) | Sumo Logic AWS CloudTrail source. |

aws/cloudtrail/cloudtrail.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ resource "random_string" "aws_random" {
1212
upper = false
1313
}
1414

15+
# Default s3 bucket acl is private, if you want to update uncomment the following block
16+
# For more details refer https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl
1517
resource "aws_s3_bucket" "s3_bucket" {
1618
for_each = toset(var.source_details.bucket_details.create_bucket ? ["s3_bucket"] : [])
1719

1820
bucket = local.bucket_name
1921
force_destroy = var.source_details.bucket_details.force_destroy_bucket
22+
}
2023

24+
resource "aws_s3_bucket_policy" "s3_bucket" {
25+
for_each = toset(var.source_details.bucket_details.create_bucket ? ["s3_bucket"] : [])
26+
27+
bucket = aws_s3_bucket.s3_bucket["s3_bucket"].id
2128
policy = templatefile("${path.module}/templates/cloudtrail_bucket_policy.tmpl", {
22-
BUCKET_NAME = local.bucket_name
29+
BUCKET_NAME = aws_s3_bucket.s3_bucket["s3_bucket"].id
2330
})
2431
}
2532

@@ -47,6 +54,7 @@ resource "aws_s3_bucket_notification" "bucket_notification" {
4754
}
4855

4956
resource "aws_cloudtrail" "cloudtrail" {
57+
depends_on = [aws_s3_bucket_policy.s3_bucket]
5058
for_each = toset(local.create_trail ? ["cloudtrail"] : [])
5159

5260
name = local.cloudtrail_name
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
6+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.16.2, < 6.0.0 |
7+
| <a name="requirement_random"></a> [random](#requirement\_random) | >=3.1.0 |
8+
| <a name="requirement_sumologic"></a> [sumologic](#requirement\_sumologic) | >= 2.28.3, < 3.0.0 |
9+
10+
## Providers
11+
12+
| Name | Version |
13+
|------|---------|
14+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.43.0 |
15+
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.0 |
16+
| <a name="provider_sumologic"></a> [sumologic](#provider\_sumologic) | 2.28.3 |
17+
18+
## Modules
19+
20+
| Name | Source | Version |
21+
|------|--------|---------|
22+
| <a name="module_cloudtrail_module"></a> [cloudtrail\_module](#module\_cloudtrail\_module) | SumoLogic/sumo-logic-integrations/sumologic//aws/cloudtrail | n/a |
23+
24+
## Resources
25+
26+
| Name | Type |
27+
|------|------|
28+
| [random_string.aws_random](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
29+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
30+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
31+
| [sumologic_caller_identity.current](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/data-sources/caller_identity) | data source |
32+
33+
## Inputs
34+
35+
| Name | Description | Type | Default | Required |
36+
|------|-------------|------|---------|:--------:|
37+
| <a name="input_sumologic_access_id"></a> [sumologic\_access\_id](#input\_sumologic\_access\_id) | Sumo Logic Access ID. Visit https://help.sumologic.com/Manage/Security/Access-Keys#Create_an_access_key | `string` | n/a | yes |
38+
| <a name="input_sumologic_access_key"></a> [sumologic\_access\_key](#input\_sumologic\_access\_key) | Sumo Logic Access Key. Visit https://help.sumologic.com/Manage/Security/Access-Keys#Create_an_access_key | `string` | n/a | yes |
39+
| <a name="input_sumologic_environment"></a> [sumologic\_environment](#input\_sumologic\_environment) | Enter au, ca, de, eu, jp, us2, in, fed or us1. For more information on Sumo Logic deployments visit https://help.sumologic.com/APIs/General-API-Information/Sumo-Logic-Endpoints-and-Firewall-Security | `string` | n/a | yes |
40+
| <a name="input_sumologic_organization_id"></a> [sumologic\_organization\_id](#input\_sumologic\_organization\_id) | You can find your org on the Preferences page in the Sumo Logic UI. For more information, see the Preferences Page topic. Your org ID will be used to configure the IAM Role for Sumo Logic AWS Sources."<br> For more details, visit https://help.sumologic.com/01Start-Here/05Customize-Your-Sumo-Logic-Experience/Preferences-Page | `string` | n/a | yes |
41+
42+
## Outputs
43+
44+
No outputs.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data "aws_region" "current" {}
2+
3+
data "aws_caller_identity" "current" {}
4+
5+
data "sumologic_caller_identity" "current" {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
locals {
2+
# AWS account details
3+
aws_account_id = data.aws_caller_identity.current.account_id
4+
aws_region = data.aws_region.current.name
5+
6+
# CloudTrail inputs
7+
bucket_name = "aws-observability-random-${random_string.aws_random.id}"
8+
path_expression = "AWSLogs/${local.aws_account_id}/CloudTrail/${local.aws_region}/*"
9+
cloudtrail_fields = { account = local.aws_account_id }
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
####### BELOW ARE REQUIRED PARAMETERS FOR TERRAFORM SCRIPT #######
2+
sumologic_environment = "<YOUR SUMO DEPLOYMENT>" # Please replace <YOUR SUMO DEPLOYMENT> (including brackets) with au, ca, de, eu, jp, us2, in, fed or us1.
3+
sumologic_organization_id = "<YOUR SUMO ORG ID>" # Please replace <YOUR SUMO ORG ID> (including brackets) with your Sumo Logic Organization ID.
4+
sumologic_access_id = "<YOUR SUMO ACCESS ID>" # Please replace <YOUR SUMO ACCESS ID> (including brackets) with your Sumo Logic Access ID.
5+
sumologic_access_key = "<YOUR SUMO ACCESS KEY>" # Please replace <YOUR SUMO ACCESS KEY> (including brackets) with your Sumo Logic Access KEY.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
resource "random_string" "aws_random" {
3+
length = 10
4+
upper = false
5+
special = false
6+
}
7+
8+
module "cloudtrail_module" {
9+
source = "SumoLogic/sumo-logic-integrations/sumologic//aws/cloudtrail"
10+
11+
create_collector = true
12+
create_trail = true
13+
sumologic_organization_id = var.sumologic_organization_id
14+
wait_for_seconds = 20
15+
16+
source_details = {
17+
source_name = "CloudTrail Logs (Region)"
18+
source_category = "aws/observability/cloudtrail/logs"
19+
description = "This source is created using Sumo Logic terraform AWS Observability module to collect AWS cloudtrail logs."
20+
collector_id = module.cloudtrail_module.sumologic_collector.collector.id
21+
bucket_details = {
22+
create_bucket = true
23+
bucket_name = local.bucket_name
24+
path_expression = local.path_expression
25+
force_destroy_bucket = false
26+
}
27+
paused = false
28+
scan_interval = 60000
29+
sumo_account_id = 926226587429
30+
cutoff_relative_time = "-1d"
31+
fields = local.cloudtrail_fields
32+
iam_details = {
33+
create_iam_role = true
34+
iam_role_arn = null
35+
}
36+
sns_topic_details = {
37+
create_sns_topic = true
38+
sns_topic_arn = null
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)