Skip to content

Commit 5c8c3e6

Browse files
authored
Merge pull request #26 from SumoLogic/hsharma-sumo-provider
Hsharma sumo provider
2 parents c9a0720 + 6c20001 commit 5c8c3e6

Some content is hidden

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

42 files changed

+886
-85
lines changed

aws/elasticloadbalancing/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ This module is used to create AWS and Sumo Logic resource to collect ELB logs fr
1313
| Name | Version |
1414
|------|---------|
1515
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
16-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.42.0 |
16+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.16.2, < 6.0.0 |
1717
| <a name="requirement_random"></a> [random](#requirement\_random) | >=3.1.0 |
18-
| <a name="requirement_sumologic"></a> [sumologic](#requirement\_sumologic) | >= 2.9.0 |
18+
| <a name="requirement_sumologic"></a> [sumologic](#requirement\_sumologic) | >= 2.28.3, < 3.0.0 |
1919
| <a name="requirement_time"></a> [time](#requirement\_time) | >=0.7.1 |
2020

2121
## Providers
2222

2323
| Name | Version |
2424
|------|---------|
25-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.42.0 |
25+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.16.2, < 6.0.0 |
2626
| <a name="provider_random"></a> [random](#provider\_random) | >=3.1.0 |
27-
| <a name="provider_sumologic"></a> [sumologic](#provider\_sumologic) | >= 2.9.0 |
27+
| <a name="provider_sumologic"></a> [sumologic](#provider\_sumologic) | >= 2.28.3, < 3.0.0 |
2828
| <a name="provider_time"></a> [time](#provider\_time) | >=0.7.1 |
2929

3030
## Modules
@@ -39,6 +39,7 @@ No modules.
3939
| [aws_iam_role.source_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
4040
| [aws_s3_bucket.s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
4141
| [aws_s3_bucket_notification.bucket_notification](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_notification) | resource |
42+
| [aws_s3_bucket_policy.dump_access_logs_to_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
4243
| [aws_serverlessapplicationrepository_cloudformation_stack.auto_enable_access_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/serverlessapplicationrepository_cloudformation_stack) | resource |
4344
| [aws_sns_topic.sns_topic](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
4445
| [aws_sns_topic_subscription.subscription](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription) | resource |
@@ -55,7 +56,7 @@ No modules.
5556

5657
| Name | Description | Type | Default | Required |
5758
|------|-------------|------|---------|:--------:|
58-
| <a name="input_app_semantic_version"></a> [app\_semantic\_version](#input\_app\_semantic\_version) | Provide the latest version of Serverless Application Repository 'sumologic-s3-logging-auto-enable'. | `string` | `"1.0.4"` | no |
59+
| <a name="input_app_semantic_version"></a> [app\_semantic\_version](#input\_app\_semantic\_version) | Provide the latest version of Serverless Application Repository 'sumologic-s3-logging-auto-enable'. | `string` | `"1.0.5"` | no |
5960
| <a name="input_auto_enable_access_logs"></a> [auto\_enable\_access\_logs](#input\_auto\_enable\_access\_logs) | New - Automatically enables access logging for newly created ELB resources to collect logs for ELB resources. This does not affect ELB resources already collecting logs.<br> Existing - Automatically enables access logging for existing ELB resources to collect logs for ELB resources.<br> Both - Automatically enables access logging for new and existing ELB resources.<br> None - Skips Automatic access Logging enable for ELB resources. | `string` | `"Both"` | no |
6061
| <a name="input_auto_enable_access_logs_options"></a> [auto\_enable\_access\_logs\_options](#input\_auto\_enable\_access\_logs\_options) | filter - provide a regex to filter the ELB for which access logs should be enabled. Empty means all resources. For eg :- 'Type': 'application'\|'type': 'application', will enable access logs for Application load balancer only.<br> remove\_on\_delete\_stack - provide true if you would like to disable access logging when you destroy the terraform resources. | <pre>object({<br> bucket_prefix = string<br> auto_enable_logging = string<br> filter = string<br> remove_on_delete_stack = bool<br> })</pre> | <pre>{<br> "auto_enable_logging": "",<br> "bucket_prefix": "",<br> "filter": "",<br> "remove_on_delete_stack": true<br>}</pre> | no |
6162
| <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 Elb Collector <Random ID>",<br> "description": "This collector is created using Sumo Logic terraform AWS ELB module to collect AWS elb logs.",<br> "fields": {}<br>}</pre> | no |

aws/elasticloadbalancing/elb.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ resource "aws_s3_bucket" "s3_bucket" {
1717

1818
bucket = local.bucket_name
1919
force_destroy = var.source_details.bucket_details.force_destroy_bucket
20+
}
2021

22+
resource "aws_s3_bucket_policy" "dump_access_logs_to_s3" {
23+
bucket = aws_s3_bucket.s3_bucket["s3_bucket"].id
2124
policy = templatefile("${path.module}/templates/elb_bucket_policy.tmpl", {
2225
BUCKET_NAME = local.bucket_name
2326
ELB_ACCCOUNT_ID = local.region_to_elb_account_id[local.aws_region]
@@ -134,6 +137,7 @@ resource "aws_sns_topic_subscription" "subscription" {
134137
}
135138

136139
# Reason to use the SAM app, is to have single source of truth for Auto Enable access logs functionality.
140+
# Ignore changes has been implemented to bypass aws resource issue: https://github.com/hashicorp/terraform-provider-aws/issues/16485
137141
resource "aws_serverlessapplicationrepository_cloudformation_stack" "auto_enable_access_logs" {
138142
for_each = toset(local.auto_enable_access_logs ? ["auto_enable_access_logs"] : [])
139143

@@ -149,4 +153,9 @@ resource "aws_serverlessapplicationrepository_cloudformation_stack" "auto_enable
149153
FilterExpression = var.auto_enable_access_logs_options.filter
150154
RemoveOnDeleteStack = var.auto_enable_access_logs_options.remove_on_delete_stack
151155
}
156+
lifecycle {
157+
ignore_changes = [
158+
parameters,tags
159+
]
160+
}
152161
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.11.1 |
10+
11+
## Providers
12+
13+
No providers.
14+
15+
## Modules
16+
17+
| Name | Source | Version |
18+
|------|--------|---------|
19+
| <a name="module_lb_module"></a> [lb\_module](#module\_lb\_module) | SumoLogic/sumo-logic-integrations/sumologic//aws/elasticloadbalancing | n/a |
20+
21+
## Resources
22+
23+
No resources.
24+
25+
## Inputs
26+
27+
| Name | Description | Type | Default | Required |
28+
|------|-------------|------|---------|:--------:|
29+
| <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 |
30+
| <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 |
31+
| <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 |
32+
| <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 |
33+
34+
## Outputs
35+
36+
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
# S3 bucket inputs
7+
bucket_name = "aws-observability-random-${random_string.aws_random.id}"
8+
path_expression = "AWSLogs/${local.aws_account_id}/clb/${local.aws_region}/*"
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
####### BELOW ARE REQUIRED PARAMETERS FOR TERRAFORM SCRIPT #######
2+
# Visit - https://help.sumologic.com/Solutions/AWS_Observability_Solution/03_Set_Up_the_AWS_Observability_Solution#sumo-logic-access-configuration-required
3+
sumologic_environment = "<YOUR SUMO DEPLOYMENT>" # Please replace <YOUR SUMO DEPLOYMENT> (including brackets) with au, ca, de, eu, jp, us2, in, fed or us1.
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.
6+
sumologic_organization_id = "<YOUR SUMO ORG ID>" # Please replace <YOUR SUMO ORG ID> (including brackets) with your Sumo Logic Organization ID.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
resource "random_string" "aws_random" {
2+
length = 10
3+
upper = false
4+
special = false
5+
}
6+
7+
module "lb_module" {
8+
source = "SumoLogic/sumo-logic-integrations/sumologic//aws/elasticloadbalancing"
9+
10+
create_collector = true
11+
sumologic_organization_id = var.sumologic_organization_id
12+
wait_for_seconds = 20
13+
14+
source_details = {
15+
source_name = "Classic Load Balancer Logs (Region)"
16+
source_category = "aws/observability/clb/logs"
17+
description = "This source is created using Sumo Logic terraform AWS Observability module to collect AWS Classic Load Balancer logs."
18+
collector_id = null
19+
bucket_details = {
20+
create_bucket = true
21+
bucket_name = local.bucket_name
22+
path_expression = local.path_expression
23+
force_destroy_bucket = false
24+
}
25+
paused = false
26+
scan_interval = 60000
27+
sumo_account_id = 926226587429
28+
cutoff_relative_time = "-1d"
29+
fields = {}
30+
iam_details = {
31+
create_iam_role = true
32+
iam_role_arn = ""
33+
}
34+
sns_topic_details = {
35+
create_sns_topic = true
36+
sns_topic_arn = ""
37+
}
38+
}
39+
auto_enable_access_logs = "Both"
40+
app_semantic_version = "1.0.6"
41+
auto_enable_access_logs_options = {
42+
bucket_prefix = "classicloadbalancing"
43+
auto_enable_logging = "ELB"
44+
filter = "'apiVersion': '2012-06-01'"
45+
remove_on_delete_stack = true
46+
}
47+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
provider "sumologic" {
2+
environment = var.sumologic_environment
3+
access_id = var.sumologic_access_id
4+
access_key = var.sumologic_access_key
5+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
variable "sumologic_environment" {
2+
type = string
3+
description = "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"
4+
5+
validation {
6+
condition = contains([
7+
"au",
8+
"ca",
9+
"de",
10+
"eu",
11+
"jp",
12+
"us1",
13+
"us2",
14+
"in",
15+
"fed"], var.sumologic_environment)
16+
error_message = "The value must be one of au, ca, de, eu, jp, us1, us2, in, or fed."
17+
}
18+
}
19+
20+
variable "sumologic_access_id" {
21+
type = string
22+
description = "Sumo Logic Access ID. Visit https://help.sumologic.com/Manage/Security/Access-Keys#Create_an_access_key"
23+
24+
validation {
25+
condition = can(regex("\\w+", var.sumologic_access_id))
26+
error_message = "The SumoLogic access ID must contain valid characters."
27+
}
28+
}
29+
30+
variable "sumologic_access_key" {
31+
type = string
32+
description = "Sumo Logic Access Key. Visit https://help.sumologic.com/Manage/Security/Access-Keys#Create_an_access_key"
33+
sensitive = true
34+
35+
validation {
36+
condition = can(regex("\\w+", var.sumologic_access_key))
37+
error_message = "The SumoLogic access key must contain valid characters."
38+
}
39+
}
40+
41+
variable "sumologic_organization_id" {
42+
type = string
43+
description = <<EOT
44+
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."
45+
For more details, visit https://help.sumologic.com/01Start-Here/05Customize-Your-Sumo-Logic-Experience/Preferences-Page
46+
EOT
47+
validation {
48+
condition = can(regex("\\w+", var.sumologic_organization_id))
49+
error_message = "The organization ID must contain valid characters."
50+
}
51+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
terraform {
2+
required_version = ">= 0.13.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.16.2, < 6.0.0"
8+
}
9+
sumologic = {
10+
version = ">= 2.28.3, < 3.0.0"
11+
source = "SumoLogic/sumologic"
12+
}
13+
time = {
14+
source = "hashicorp/time"
15+
version = ">= 0.11.1"
16+
}
17+
random = {
18+
source = "hashicorp/random"
19+
version = ">= 3.1.0"
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)