Skip to content

Commit b3fb3b8

Browse files
feat: Add support for workspace configuration (#25)
Co-authored-by: Bryant Biggs <[email protected]>
1 parent 04e9410 commit b3fb3b8

File tree

8 files changed

+80
-6
lines changed

8 files changed

+80
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.103.0
3+
rev: v1.104.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
5858
| Name | Version |
5959
|------|---------|
6060
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
61-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
61+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.22 |
6262

6363
## Providers
6464

6565
| Name | Version |
6666
|------|---------|
67-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
67+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.22 |
6868

6969
## Modules
7070

@@ -78,6 +78,7 @@ No modules.
7878
| [aws_prometheus_alert_manager_definition.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_alert_manager_definition) | resource |
7979
| [aws_prometheus_rule_group_namespace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_rule_group_namespace) | resource |
8080
| [aws_prometheus_workspace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_workspace) | resource |
81+
| [aws_prometheus_workspace_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_workspace_configuration) | resource |
8182

8283
## Inputs
8384

@@ -93,8 +94,10 @@ No modules.
9394
| <a name="input_create_alert_manager"></a> [create\_alert\_manager](#input\_create\_alert\_manager) | Controls whether an Alert Manager definition is created along with the AMP workspace | `bool` | `true` | no |
9495
| <a name="input_create_workspace"></a> [create\_workspace](#input\_create\_workspace) | Determines whether a workspace will be created or to use an existing workspace | `bool` | `true` | no |
9596
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN of the KMS Key to for encryption at rest | `string` | `null` | no |
97+
| <a name="input_limits_per_label_set"></a> [limits\_per\_label\_set](#input\_limits\_per\_label\_set) | Configuration block for setting limits on metrics with specific label sets | <pre>list(object({<br/> label_set = map(string)<br/> limits = object({<br/> max_series = number<br/> })<br/> }))</pre> | `null` | no |
9698
| <a name="input_logging_configuration"></a> [logging\_configuration](#input\_logging\_configuration) | The logging configuration of the prometheus workspace. | <pre>object({<br/> create_log_group = optional(bool, true)<br/> logging_configuration = optional(string)<br/> })</pre> | `null` | no |
9799
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the Region set in the provider configuration | `string` | `null` | no |
100+
| <a name="input_retention_period_in_days"></a> [retention\_period\_in\_days](#input\_retention\_period\_in\_days) | Number of days to retain metric data in the workspace | `number` | `null` | no |
98101
| <a name="input_rule_group_namespaces"></a> [rule\_group\_namespaces](#input\_rule\_group\_namespaces) | A map of one or more rule group namespace definitions | <pre>map(object({<br/> name = string<br/> data = string<br/> }))</pre> | `null` | no |
99102
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
100103
| <a name="input_workspace_alias"></a> [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 |

examples/complete/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Note that this example may create resources which will incur monetary charges on
2424
| Name | Version |
2525
|------|---------|
2626
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
27-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
27+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.22 |
2828

2929
## Providers
3030

examples/complete/main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ module "prometheus" {
2121
# log_group_arn = "${aws_cloudwatch_log_group.this.arn}:*"
2222
}
2323

24+
retention_period_in_days = 60
25+
26+
limits_per_label_set = [
27+
{
28+
label_set = {
29+
"env" = "dev"
30+
}
31+
limits = {
32+
max_series = 100000
33+
}
34+
},
35+
{
36+
label_set = {
37+
"env" = "prod"
38+
}
39+
limits = {
40+
max_series = 400000
41+
}
42+
}
43+
]
44+
2445
create_alert_manager = true
2546
alert_manager_definition = <<-EOT
2647
alertmanager_config: |

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 6.0"
7+
version = ">= 6.22"
88
}
99
}
1010
}

main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,35 @@ resource "aws_prometheus_workspace" "this" {
2525
tags = var.tags
2626
}
2727

28+
################################################################################
29+
# Workspace Configuration
30+
################################################################################
31+
32+
resource "aws_prometheus_workspace_configuration" "this" {
33+
count = var.create && var.create_workspace ? 1 : 0
34+
35+
region = var.region
36+
37+
retention_period_in_days = var.retention_period_in_days
38+
workspace_id = local.workspace_id
39+
40+
dynamic "limits_per_label_set" {
41+
for_each = var.limits_per_label_set
42+
43+
content {
44+
label_set = limits_per_label_set.value.label_set
45+
46+
dynamic "limits" {
47+
for_each = limits_per_label_set.value.limits
48+
49+
content {
50+
max_series = limits.value.max_series
51+
}
52+
}
53+
}
54+
}
55+
}
56+
2857
################################################################################
2958
# Cloudwatch Log Group
3059
################################################################################

variables.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ variable "kms_key_arn" {
5353
default = null
5454
}
5555

56+
################################################################################
57+
# Workspace Configuration
58+
################################################################################
59+
60+
variable "retention_period_in_days" {
61+
description = "Number of days to retain metric data in the workspace"
62+
type = number
63+
default = null
64+
}
65+
66+
variable "limits_per_label_set" {
67+
description = "Configuration block for setting limits on metrics with specific label sets"
68+
type = list(object({
69+
label_set = map(string)
70+
limits = object({
71+
max_series = number
72+
})
73+
}))
74+
default = null
75+
}
76+
5677
################################################################################
5778
# CloudWatch Log Group
5879
################################################################################

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 6.0"
7+
version = ">= 6.22"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)