Skip to content

Commit a96459e

Browse files
authored
Merge pull request #6 from SumoLogic/aws
Modules for AWSS
2 parents 4e64b5d + 44d1805 commit a96459e

File tree

113 files changed

+4667
-519
lines changed

Some content is hidden

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

113 files changed

+4667
-519
lines changed

aws/cloudtrail/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@ This module is used to create AWS and Sumo Logic resource to collect CloudTrail
1313
| Name | Version |
1414
|------|---------|
1515
| terraform | >= 0.13.0 |
16-
| aws | ~> 3.29.1 |
17-
| sumologic | ~> 2.6.0 |
18-
| time | 0.7.1 |
16+
| aws | >= 3.42.0 |
17+
| random | >=3.1.0 |
18+
| sumologic | >= 2.9.0 |
19+
| time | >=0.7.1 |
1920

2021
## Providers
2122

2223
| Name | Version |
2324
|------|---------|
24-
| aws | ~> 3.29.1 |
25-
| sumologic | ~> 2.6.0 |
26-
| time | 0.7.1 |
25+
| aws | >= 3.42.0 |
26+
| random | >=3.1.0 |
27+
| sumologic | >= 2.9.0 |
28+
| time | >=0.7.1 |
2729

2830
## Inputs
2931

3032
| Name | Description | Type | Default | Required |
3133
|------|-------------|------|---------|:--------:|
32-
| 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"<br>}</pre> | no |
33-
| 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 <AWS Account Id>",<br> "description": "This collector is created using Sumo Logic terraform AWS cloudtrail module to collect AWS cloudtrail logs.",<br> "fields": {}<br>}</pre> | no |
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 |
3436
| create\_collector | Provide "true" if you would like to create the Sumo Logic Collector. | `bool` | n/a | yes |
3537
| 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 |
36-
| 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_role_arn = string<br> sns_topic_arn = string<br> })</pre> | <pre>{<br> "bucket_details": {<br> "bucket_name": "cloudtrail-logs-accountid-region",<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_role_arn": "",<br> "paused": false,<br> "scan_interval": 300000,<br> "sns_topic_arn": "",<br> "source_category": "Labs/aws/cloudtrail",<br> "source_name": "CloudTrail Source",<br> "sumo_account_id": 926226587429<br>}</pre> | no |
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_role_arn = string<br> sns_topic_arn = string<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_role_arn": "",<br> "paused": false,<br> "scan_interval": 300000,<br> "sns_topic_arn": "",<br> "source_category": "Labs/aws/cloudtrail",<br> "source_name": "CloudTrail Source",<br> "sumo_account_id": 926226587429<br>}</pre> | no |
3739
| 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 |
3840

3941
## Outputs
@@ -46,5 +48,6 @@ This module is used to create AWS and Sumo Logic resource to collect CloudTrail
4648
| aws\_s3\_bucket\_notification | AWS S3 Bucket Notification attached to the AWS S3 Bucket |
4749
| aws\_sns\_subscription | AWS SNS subscription to Sumo Logic AWS CloudTrail source. |
4850
| aws\_sns\_topic | AWS SNS topic attached to the AWS S3 bucket. |
51+
| random\_string | Random String value created. |
4952
| sumologic\_collector | Sumo Logic hosted collector. |
5053
| sumologic\_source | Sumo Logic AWS CloudTrail source. |

aws/cloudtrail/cloudtrail.tf

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
# 5. Create the source either in the collector created or in the collector id provided.
77
# 6. Create SNS Subscription to be attached to the source and SNS Topic.
88

9+
resource "random_string" "aws_random" {
10+
length = 10
11+
special = false
12+
upper = false
13+
}
14+
915
resource "aws_s3_bucket" "s3_bucket" {
1016
for_each = toset(var.source_details.bucket_details.create_bucket ? ["s3_bucket"] : [])
1117

@@ -20,11 +26,11 @@ resource "aws_s3_bucket" "s3_bucket" {
2026
resource "aws_sns_topic" "sns_topic" {
2127
for_each = toset(local.create_sns_topic ? ["sns_topic"] : [])
2228

23-
name = "SumoLogic-Terraform-CloudTrail-Module-${local.aws_account_id}"
29+
name = "SumoLogic-Terraform-CloudTrail-Module-${random_string.aws_random.id}"
2430
policy = templatefile("${path.module}/templates/sns_topic_policy.tmpl", {
2531
BUCKET_NAME = local.bucket_name,
2632
AWS_REGION = local.aws_region,
27-
SNS_TOPIC_NAME = "SumoLogic-Terraform-CloudTrail-Module-${local.aws_account_id}",
33+
SNS_TOPIC_NAME = "SumoLogic-Terraform-CloudTrail-Module-${random_string.aws_random.id}",
2834
AWS_ACCOUNT = local.aws_account_id
2935
})
3036
}
@@ -43,7 +49,7 @@ resource "aws_s3_bucket_notification" "bucket_notification" {
4349
resource "aws_cloudtrail" "cloudtrail" {
4450
for_each = toset(local.create_trail ? ["cloudtrail"] : [])
4551

46-
name = var.cloudtrail_details.name
52+
name = local.cloudtrail_name
4753
include_global_service_events = var.cloudtrail_details.include_global_service_events
4854
s3_bucket_name = var.source_details.bucket_details.create_bucket ? aws_s3_bucket.s3_bucket["s3_bucket"].id : local.bucket_name
4955
is_multi_region_trail = var.cloudtrail_details.is_multi_region_trail
@@ -53,7 +59,7 @@ resource "aws_cloudtrail" "cloudtrail" {
5359
resource "aws_iam_role" "source_iam_role" {
5460
for_each = toset(local.create_iam_role ? ["source_iam_role"] : [])
5561

56-
name = "SumoLogic-Terraform-CloudTrail-Module-${local.aws_account_id}-${local.aws_region}"
62+
name = "SumoLogic-Terraform-CloudTrail-Module-${random_string.aws_random.id}"
5763
path = "/"
5864

5965
assume_role_policy = templatefile("${path.module}/templates/sumologic_assume_role.tmpl", {
@@ -68,7 +74,7 @@ resource "aws_iam_role" "source_iam_role" {
6874
resource "aws_iam_policy" "iam_policy" {
6975
for_each = toset(local.create_iam_role ? ["iam_policy"] : [])
7076

71-
name = "SumoLogicCloudTrailSource-${local.aws_account_id}-${local.aws_region}"
77+
name = "SumoLogicCloudTrailSource-${random_string.aws_random.id}"
7278
policy = templatefile("${path.module}/templates/sumologic_source_policy.tmpl", {
7379
BUCKET_NAME = local.bucket_name
7480
})

aws/cloudtrail/locals.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ locals {
55
aws_region = data.aws_region.current.id
66

77
# Get the default collector name if no collector name is provided.
8-
collector_name = var.collector_details.collector_name == "SumoLogic CloudTrail Collector <AWS Account Id>" ? "SumoLogic CloudTrail Collector ${local.aws_account_id}" : var.collector_details.collector_name
8+
collector_name = var.collector_details.collector_name == "SumoLogic CloudTrail Collector <Random ID>" ? "SumoLogic CloudTrail Collector ${random_string.aws_random.id}" : var.collector_details.collector_name
9+
10+
# Get the default cloudtrail name if default is provided.
11+
cloudtrail_name = var.cloudtrail_details.name == "SumoLogic-Terraform-CloudTrail-random-id" ? "SumoLogic-Terraform-CloudTrail-${random_string.aws_random.id}" : var.cloudtrail_details.name
912

1013
# Get the default bucket name when no bucket is provided and create_bucket is true.
11-
bucket_name = var.source_details.bucket_details.create_bucket && var.source_details.bucket_details.bucket_name == "cloudtrail-logs-accountid-region" ? "cloudtrail-logs-${local.aws_account_id}-${local.aws_region}" : var.source_details.bucket_details.bucket_name
14+
bucket_name = var.source_details.bucket_details.create_bucket && var.source_details.bucket_details.bucket_name == "cloudtrail-logs-random-id" ? "cloudtrail-logs-${random_string.aws_random.id}" : var.source_details.bucket_details.bucket_name
1215

1316
# Create IAM role condition if no IAM ROLE ARN is provided.
1417
create_iam_role = var.source_details.iam_role_arn != "" ? false : true

aws/cloudtrail/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
output "random_string" {
2+
value = random_string.aws_random
3+
description = "Random String value created."
4+
}
5+
16
output "aws_s3_bucket" {
27
value = var.source_details.bucket_details.create_bucket ? aws_s3_bucket.s3_bucket : {}
38
description = "AWS S3 Bucket name created to Store the CloudTrail logs."

aws/cloudtrail/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ variable "collector_details" {
1111
})
1212
description = "Provide details for the Sumo Logic collector. If not provided, then defaults will be used."
1313
default = {
14-
collector_name = "SumoLogic CloudTrail Collector <AWS Account Id>"
14+
collector_name = "SumoLogic CloudTrail Collector <Random ID>"
1515
description = "This collector is created using Sumo Logic terraform AWS cloudtrail module to collect AWS cloudtrail logs."
1616
fields = {}
1717
}
@@ -45,7 +45,7 @@ variable "source_details" {
4545
collector_id = ""
4646
bucket_details = {
4747
create_bucket = true
48-
bucket_name = "cloudtrail-logs-accountid-region"
48+
bucket_name = "cloudtrail-logs-random-id"
4949
path_expression = "AWSLogs/<ACCOUNT-ID>/CloudTrail/<REGION-NAME>/*"
5050
force_destroy_bucket = true
5151
}
@@ -91,7 +91,7 @@ variable "cloudtrail_details" {
9191
})
9292
description = "Provide details for the AWS CloudTrail. If not provided, then defaults will be used."
9393
default = {
94-
name = "SumoLogic-Terraform-CloudTrail"
94+
name = "SumoLogic-Terraform-CloudTrail-random-id"
9595
is_multi_region_trail = false
9696
is_organization_trail = false
9797
include_global_service_events = false

aws/cloudtrail/versions.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = "~> 3.29.1"
7+
version = ">= 3.42.0"
88
}
99
sumologic = {
10-
version = "~> 2.6.0"
10+
version = ">= 2.9.0"
1111
source = "SumoLogic/sumologic"
1212
}
1313
time = {
1414
source = "hashicorp/time"
15-
version = "0.7.1"
15+
version = ">=0.7.1"
16+
}
17+
random = {
18+
source = "hashicorp/random"
19+
version = ">=3.1.0"
1620
}
1721
}
1822
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# SumoLogic-AWS-CloudWatchLogsForwarder
2+
3+
This module is used to create the SumoLogic AWS HTTP source to collect AWS CloudWatch logs. Features include
4+
- Create AWS resources to setup IAM Roles, SQS, SNS, Metric Alarm, Lambda functions.
5+
- Create Sumo Logic hosted collector. Existing collector can also be used.
6+
- Create Sumo Logic HTTP Source for logs.
7+
- Auto enable logs subscription for Existing and New log groups after installing the module.
8+
9+
## Requirements
10+
11+
| Name | Version |
12+
|------|---------|
13+
| terraform | >= 0.13.0 |
14+
| aws | >= 3.42.0 |
15+
| random | >= 3.1.0 |
16+
| sumologic | >= 2.9.0 |
17+
18+
## Providers
19+
20+
| Name | Version |
21+
|------|---------|
22+
| aws | >= 3.42.0 |
23+
| random | >= 3.1.0 |
24+
| sumologic | >= 2.9.0 |
25+
26+
## Inputs
27+
28+
| Name | Description | Type | Default | Required |
29+
|------|-------------|------|---------|:--------:|
30+
| auto\_enable\_logs\_subscription | New - Automatically subscribes new log groups to send logs to Sumo Logic.<br> Existing - Automatically subscribes existing log groups to send logs to Sumo Logic.<br> Both - Automatically subscribes new and existing log groups.<br> None - Skips Automatic subscription. | `string` | `"Both"` | no |
31+
| auto\_enable\_logs\_subscription\_options | filter - Enter regex for matching logGroups. Regex will check for the name. Visit https://help.sumologic.com/03Send-Data/Collect-from-Other-Data-Sources/Auto-Subscribe_AWS_Log_Groups_to_a_Lambda_Function#Configuring_parameters | <pre>object({<br> filter = string<br> })</pre> | <pre>{<br> "filter": "lambda"<br>}</pre> | no |
32+
| 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 CloudWatch Logs Collector <Random ID>",<br> "description": "This collector is created using Sumo Logic terraform AWS CloudWatch Logs forwarder to collect AWS cloudwatch logs.",<br> "fields": {}<br>}</pre> | no |
33+
| create\_collector | Provide "true" if you would like to create the Sumo Logic Collector. | `bool` | n/a | yes |
34+
| email\_id | Email for receiving alerts. A confirmation email is sent after the deployment is complete. It can be confirmed to subscribe for alerts. | `string` | `"[email protected]"` | no |
35+
| include\_log\_group\_info | Enable loggroup/logstream values in logs. | `bool` | `true` | no |
36+
| log\_format | Service for Cloudwatch logs source. | `string` | `"Others"` | no |
37+
| log\_stream\_prefix | LogStream name prefixes to filter by logStream. Please note this is separate from a logGroup. This is used only to send certain logStreams within a Cloudwatch logGroup(s). LogGroups still need to be subscribed to the created Lambda function regardless of this input value. | `list(string)` | `[]` | no |
38+
| source\_details | Provide details for the Sumo Logic HTTP 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> fields = map(string)<br> })</pre> | <pre>{<br> "collector_id": "",<br> "description": "This source is created using Sumo Logic terraform AWS CloudWatch Logs forwarder to collect AWS cloudwatch logs.",<br> "fields": {},<br> "source_category": "Labs/aws/cloudwatch",<br> "source_name": "CloudWatch Logs Source"<br>}</pre> | no |
39+
| workers | Number of lambda function invocations for Cloudwatch logs source Dead Letter Queue processing. | `number` | `4` | no |
40+
41+
## Outputs
42+
43+
| Name | Description |
44+
|------|-------------|
45+
| aws\_cloudwatch\_log\_group | AWS Log group created to attach to the lambda function. |
46+
| aws\_cloudwatch\_metric\_alarm | AWS CLoudWatch metric alarm. |
47+
| aws\_cw\_lambda\_function | AWS Lambda fucntion to send logs to Sumo Logic. |
48+
| aws\_iam\_role | AWS IAM role with permission to setup lambda. |
49+
| aws\_serverlessapplicationrepository\_cloudformation\_stack | AWS CloudFormation stack for Auto Enable logs subscription. |
50+
| aws\_sns\_topic | AWS SNS topic |
51+
| aws\_sqs\_queue | AWS SQS queue to Store the Failed data. |
52+
| random\_string | Random String value created. |
53+
| sumologic\_collector | Sumo Logic hosted collector. |
54+
| sumologic\_source | Sumo Logic HTTP source. |

0 commit comments

Comments
 (0)