Skip to content
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

if subsystem_name is empty, do not add as param #53

Merged
merged 6 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/firehose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ then the CloudWatch metric stream must be configured with the same format, confi
| <a name="input_logs_enable"></a> [logs_enable](#input\_logs_enable) | Enble sending logs to Coralogix | `bool` | `false` | no |
| <a name="input_source_type_logs"></a> [source_type_logs](#input\_source_type_logs) | The source_type of kinesis firehose: KinesisStreamAsSource or DirectPut | `string` | `DirectPut` | no |
| <a name="input_kinesis_stream_arn"></a> [kinesis_stream_arn](#input\_kinesis_stream_arn) | The kinesis stream name for the logs - used in kinesis stream as a source | `string` | `""` | no |
| <a name="input_kinesis_stream_arn"></a> [kinesis_stream_arn](#input\_integration_type_logs) | The integration type of the firehose delivery stream: 'CloudWatch_JSON', 'WAF', 'CloudWatch_CloudTrail', 'EksFargate', 'Default', 'RawText' | `string` | `Default` | no |
| <a name="input_integration_type_logs"></a> [integration_type_logs](#input\_integration_type_logs) | The integration type of the firehose delivery stream: 'CloudWatch_JSON', 'WAF', 'CloudWatch_CloudTrail', 'EksFargate', 'Default', 'RawText' | `string` | `Default` | no |
| <a name="input_dynamic_metadata_logs"></a> [dynamic_metadata_logs](#input\_dynamic_metadata_logs) | Dynamic values search for specific fields in the logs to populate the fields | `bool` | `false` | no |


Expand Down
91 changes: 60 additions & 31 deletions modules/firehose/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ locals {
managed-by = "coralogix-terraform"
custom_endpoint = var.coralogix_firehose_custom_endpoint != null ? var.coralogix_firehose_custom_endpoint : ""
})
application_name = var.application_name == null ? "coralogix-${var.firehose_stream}" : var.application_name
}

data "aws_caller_identity" "current_identity" {}
Expand Down Expand Up @@ -172,24 +171,36 @@ resource "aws_kinesis_firehose_delivery_stream" "coralogix_stream_logs_kinesis_s
request_configuration {
content_encoding = "GZIP"

common_attributes {
name = "integrationType"
value = var.integration_type_logs
dynamic "common_attributes" {
for_each = var.integration_type_logs == null ? [] : [1]
content {
name = "integrationType"
value = var.integration_type_logs
}
}

common_attributes {
name = "applicationName"
value = local.application_name
dynamic "common_attributes" {
for_each = var.application_name == null ? [] : [1]
content {
name = "applicationName"
value = var.application_name
}
}

common_attributes {
name = "subsystemName"
value = var.subsystem_name
dynamic "common_attributes" {
for_each = var.subsystem_name == null ? [] : [1]
content {
name = "subsystemName"
value = var.subsystem_name
}
}

common_attributes {
name = "dynamicMetadata"
value = var.dynamic_metadata_logs
dynamic "common_attributes" {
for_each = var.dynamic_metadata_logs == null ? [] : [1]
content {
name = "dynamicMetadata"
value = var.dynamic_metadata_logs
}
}
}
}
Expand Down Expand Up @@ -228,24 +239,36 @@ resource "aws_kinesis_firehose_delivery_stream" "coralogix_stream_logs_direct_pu
request_configuration {
content_encoding = "GZIP"

common_attributes {
name = "integrationType"
value = var.integration_type_logs
dynamic "common_attributes" {
for_each = var.integration_type_logs == null ? [] : [1]
content {
name = "integrationType"
value = var.integration_type_logs
}
}

common_attributes {
name = "applicationName"
value = local.application_name
dynamic "common_attributes" {
for_each = var.application_name == null ? [] : [1]
content {
name = "applicationName"
value = var.application_name
}
}

common_attributes {
name = "subsystemName"
value = var.subsystem_name
dynamic "common_attributes" {
for_each = var.subsystem_name == null ? [] : [1]
content {
name = "subsystemName"
value = var.subsystem_name
}
}

common_attributes {
name = "dynamicMetadata"
value = var.dynamic_metadata_logs
dynamic "common_attributes" {
for_each = var.dynamic_metadata_logs == null ? [] : [1]
content {
name = "dynamicMetadata"
value = var.dynamic_metadata_logs
}
}
}
}
Expand Down Expand Up @@ -464,14 +487,20 @@ resource "aws_kinesis_firehose_delivery_stream" "coralogix_stream_metrics" {
request_configuration {
content_encoding = "GZIP"

common_attributes {
name = "integrationType"
value = var.integration_type_metrics
dynamic "common_attributes" {
for_each = var.integration_type_metrics == null ? [] : [1]
content {
name = "integrationType"
value = var.integration_type_metrics
}
}

common_attributes {
name = "applicationName"
value = local.application_name
dynamic "common_attributes" {
for_each = var.application_name == null ? [] : [1]
content {
name = "applicationName"
value = var.application_name
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions modules/firehose/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ variable "output_format" {
variable "integration_type_metrics" {
description = "The integration type of the firehose delivery stream: 'CloudWatch_Metrics_JSON' or 'CloudWatch_Metrics_OpenTelemetry070'"
type = string
default = "CloudWatch_Metrics_OpenTelemetry070"
default = ""
}

variable "application_name" {
Expand All @@ -61,7 +61,7 @@ variable "application_name" {
variable "subsystem_name" {
description = "The subsystem name of your application in Coralogix"
type = string
default = ""
default = null
}

variable "user_supplied_tags" {
Expand Down Expand Up @@ -109,11 +109,11 @@ variable "kinesis_stream_arn" {
variable "integration_type_logs" {
description = "The integration type of the firehose delivery stream: 'CloudWatch_JSON', 'WAF', 'CloudWatch_CloudTrail', 'EksFargate', 'Default', 'RawText'"
type = string
default = "Default"
default = null
}

variable "dynamic_metadata_logs" {
description = "Dynamic values search for specific fields in the logs to populate the fields"
type = bool
default = false
default = null
}