Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
loki/tools/lambda-promtail/variables.tf

122 lines
3.5 KiB

refactor(lambda-promtail): apply terraform best practices (#8750) **What this PR does / why we need it**: I would like to offer this PR as a suggestion to improve the lambda-promtail terraform-module. I forked it to be able to deploy it more than once in an AWS account. I also applied terraform best-practices. I was hoping that perhaps these changes could be merged into upstream as well. Unlike https://github.com/grafana/loki/pull/8549 , I unfortunately did not end up making a separate commit for each change. If you would like me to create one or more issue(s) to address the points below, I'd be happy to do that as well. List of improvements: 1. Added `var.name` (defaults to lambda-promtail) so that this module can be deployed multiple times in the same AWS account. This allows us to define unique, non-conflicting names for: * the Lambda function * the CloudWatch log-group * the IAM role 2. Split IAM role policies per component; only assign permissions when required 3. Scope down permissions of the IAM role policies 4. During terraform-destroy, ensure CloudWatch log-group is removed **after** the lambda-function. An accidental invocation of the function could re-create an already destroyed log-group, leaving an orphaned log-group List of style changes: 1. Rename resources to `this` when there is only one instance of this resource-type 2. Add newline after `count|before_each` and before `depends_on` 3. Group resources together and add a section comment 4. Add missing(?) statement-id to S3 AWS lambda permission Misc. 1. I added a `moves.tf` file to facilitate moving renamed resources in existing terraform statefiles. This prevents some resources from recreated. Can also be removed. These changes are backwards compatible, even though some resources will end up being re-created. A `terraform apply` should succeed (it did for me). **Checklist** - [X] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) Signed-off-by: Mitch Hulscher <mitch.hulscher@lib.io>
3 years ago
variable "name" {
type = string
description = "Name used for created AWS resources."
default = "lambda_promtail"
}
variable "write_address" {
type = string
description = "This is the Loki Write API compatible endpoint that you want to write logs to, either promtail or Loki."
default = "http://localhost:8080/loki/api/v1/push"
}
variable "bucket_names" {
type = set(string)
description = "List of S3 bucket names to create Event Notifications for."
default = []
}
variable "log_group_names" {
type = set(string)
description = "List of CloudWatch Log Group names to create Subscription Filters for."
default = []
}
variable "lambda_promtail_image" {
type = string
description = "The ECR image URI to pull and use for lambda-promtail."
default = ""
}
variable "username" {
type = string
description = "The basic auth username, necessary if writing directly to Grafana Cloud Loki."
default = ""
}
variable "password" {
type = string
description = "The basic auth password, necessary if writing directly to Grafana Cloud Loki."
sensitive = true
default = ""
}
variable "bearer_token" {
type = string
description = "The bearer token, necessary if target endpoint requires it."
sensitive = true
default = ""
}
variable "tenant_id" {
type = string
description = "Tenant ID to be added when writing logs from lambda-promtail."
default = ""
}
variable "keep_stream" {
type = string
description = "Determines whether to keep the CloudWatch Log Stream value as a Loki label when writing logs from lambda-promtail."
default = "false"
}
variable "print_log_line" {
type = string
description = "Determines whether we want the lambda to output the parsed log line before sending it on to promtail. Value needed to disable is the string 'false'"
default = "true"
}
variable "extra_labels" {
type = string
description = "Comma separated list of extra labels, in the format 'name1,value1,name2,value2,...,nameN,valueN' to add to entries forwarded by lambda-promtail."
default = ""
}
variable "omit_extra_labels_prefix" {
type = bool
description = "Whether or not to omit the prefix `__extra_` from extra labels defined in the variable `extra_labels`."
default = false
}
variable "batch_size" {
type = string
description = "Determines when to flush the batch of logs (bytes)."
default = ""
}
variable "lambda_vpc_subnets" {
type = list(string)
description = "List of subnet IDs associated with the Lambda function."
default = []
}
variable "lambda_vpc_security_groups" {
type = list(string)
description = "List of security group IDs associated with the Lambda function."
default = []
}
variable "kms_key_arn" {
type = string
description = "kms key arn for encrypting env vars."
default = ""
}
variable "skip_tls_verify" {
type = string
description = "Determines whether to verify the TLS certificate"
default = "false"
}
variable "kinesis_stream_name" {
type = set(string)
description = "Enter kinesis name if kinesis stream is configured as event source in lambda."
default = []
}
variable "sqs_enabled" {
type = bool
description = "Enables sending S3 logs to an SQS queue which will trigger lambda-promtail, unsuccessfully processed message are sent to a dead-letter-queue"
default = false
}