diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9223e3c..efc335f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.103.0 + rev: v1.104.0 hooks: - id: terraform_fmt - id: terraform_docs diff --git a/README.md b/README.md index abeb46b..d44e096 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.5.7 | -| [aws](#requirement\_aws) | >= 6.0 | +| [aws](#requirement\_aws) | >= 6.22 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 6.0 | +| [aws](#provider\_aws) | >= 6.22 | ## Modules @@ -78,6 +78,7 @@ No modules. | [aws_prometheus_alert_manager_definition.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_alert_manager_definition) | resource | | [aws_prometheus_rule_group_namespace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_rule_group_namespace) | resource | | [aws_prometheus_workspace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_workspace) | resource | +| [aws_prometheus_workspace_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_workspace_configuration) | resource | ## Inputs @@ -93,8 +94,10 @@ No modules. | [create\_alert\_manager](#input\_create\_alert\_manager) | Controls whether an Alert Manager definition is created along with the AMP workspace | `bool` | `true` | no | | [create\_workspace](#input\_create\_workspace) | Determines whether a workspace will be created or to use an existing workspace | `bool` | `true` | no | | [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN of the KMS Key to for encryption at rest | `string` | `null` | no | +| [limits\_per\_label\_set](#input\_limits\_per\_label\_set) | Configuration block for setting limits on metrics with specific label sets |
list(object({
label_set = map(string)
limits = object({
max_series = number
})
})) | `null` | no |
| [logging\_configuration](#input\_logging\_configuration) | The logging configuration of the prometheus workspace. | object({
create_log_group = optional(bool, true)
logging_configuration = optional(string)
}) | `null` | no |
| [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the Region set in the provider configuration | `string` | `null` | no |
+| [retention\_period\_in\_days](#input\_retention\_period\_in\_days) | Number of days to retain metric data in the workspace | `number` | `null` | no |
| [rule\_group\_namespaces](#input\_rule\_group\_namespaces) | A map of one or more rule group namespace definitions | map(object({
name = string
data = string
})) | `null` | no |
| [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
| [workspace\_alias](#input\_workspace\_alias) | The alias of the prometheus workspace. See more in the [AWS Docs](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-create-workspace.html) | `string` | `null` | no |
diff --git a/examples/complete/README.md b/examples/complete/README.md
index 5eb3555..b49dbf5 100644
--- a/examples/complete/README.md
+++ b/examples/complete/README.md
@@ -24,7 +24,7 @@ Note that this example may create resources which will incur monetary charges on
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.5.7 |
-| [aws](#requirement\_aws) | >= 6.0 |
+| [aws](#requirement\_aws) | >= 6.22 |
## Providers
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 4407371..b5c38ed 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -21,6 +21,27 @@ module "prometheus" {
# log_group_arn = "${aws_cloudwatch_log_group.this.arn}:*"
}
+ retention_period_in_days = 60
+
+ limits_per_label_set = [
+ {
+ label_set = {
+ "env" = "dev"
+ }
+ limits = {
+ max_series = 100000
+ }
+ },
+ {
+ label_set = {
+ "env" = "prod"
+ }
+ limits = {
+ max_series = 400000
+ }
+ }
+ ]
+
create_alert_manager = true
alert_manager_definition = <<-EOT
alertmanager_config: |
diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf
index db13b0a..0cf1cd7 100644
--- a/examples/complete/versions.tf
+++ b/examples/complete/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 6.0"
+ version = ">= 6.22"
}
}
}
diff --git a/main.tf b/main.tf
index 5673070..559508b 100644
--- a/main.tf
+++ b/main.tf
@@ -25,6 +25,35 @@ resource "aws_prometheus_workspace" "this" {
tags = var.tags
}
+################################################################################
+# Workspace Configuration
+################################################################################
+
+resource "aws_prometheus_workspace_configuration" "this" {
+ count = var.create && var.create_workspace ? 1 : 0
+
+ region = var.region
+
+ retention_period_in_days = var.retention_period_in_days
+ workspace_id = local.workspace_id
+
+ dynamic "limits_per_label_set" {
+ for_each = var.limits_per_label_set
+
+ content {
+ label_set = limits_per_label_set.value.label_set
+
+ dynamic "limits" {
+ for_each = limits_per_label_set.value.limits
+
+ content {
+ max_series = limits.value.max_series
+ }
+ }
+ }
+ }
+}
+
################################################################################
# Cloudwatch Log Group
################################################################################
diff --git a/variables.tf b/variables.tf
index 131ce82..d4e79c4 100644
--- a/variables.tf
+++ b/variables.tf
@@ -53,6 +53,27 @@ variable "kms_key_arn" {
default = null
}
+################################################################################
+# Workspace Configuration
+################################################################################
+
+variable "retention_period_in_days" {
+ description = "Number of days to retain metric data in the workspace"
+ type = number
+ default = null
+}
+
+variable "limits_per_label_set" {
+ description = "Configuration block for setting limits on metrics with specific label sets"
+ type = list(object({
+ label_set = map(string)
+ limits = object({
+ max_series = number
+ })
+ }))
+ default = null
+}
+
################################################################################
# CloudWatch Log Group
################################################################################
diff --git a/versions.tf b/versions.tf
index db13b0a..0cf1cd7 100644
--- a/versions.tf
+++ b/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 6.0"
+ version = ">= 6.22"
}
}
}