Skip to content

Commit 53fed8d

Browse files
schniberSamuel CHNIBER
andauthored
fix: Fix dependencies and implementation of the logging configuration support feature (#9)
* fix dependencies between the workspace and the alert manager definition and rule group namespace + addition of logging configuration support * fix tf version to be upper than 4.35 * update after iteration on the PR Co-authored-by: Samuel CHNIBER <[email protected]>
1 parent f4b0a5b commit 53fed8d

File tree

7 files changed

+39
-9
lines changed

7 files changed

+39
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
5757
| Name | Version |
5858
|------|---------|
5959
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
60-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.1 |
60+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.35 |
6161

6262
## Providers
6363

6464
| Name | Version |
6565
|------|---------|
66-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.1 |
66+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.35 |
6767

6868
## Modules
6969

@@ -84,6 +84,7 @@ No modules.
8484
| <a name="input_alert_manager_definition"></a> [alert\_manager\_definition](#input\_alert\_manager\_definition) | The alert manager definition that you want to be applied. See more in the [AWS Docs](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alert-manager.html) | `string` | `"alertmanager_config: |\n route:\n receiver: 'default'\n receivers:\n - name: 'default'\n"` | no |
8585
| <a name="input_create"></a> [create](#input\_create) | Determines whether a resources will be created | `bool` | `true` | no |
8686
| <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 |
87+
| <a name="input_logging_configuration"></a> [logging\_configuration](#input\_logging\_configuration) | The logging configuration of the prometheus workspace. | `map(string)` | `{}` | no |
8788
| <a name="input_rule_group_namespaces"></a> [rule\_group\_namespaces](#input\_rule\_group\_namespaces) | A map of one or more rule group namespace definitions | `map(any)` | `{}` | no |
8889
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
8990
| <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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ 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) | >= 0.13.1 |
27-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.1 |
27+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.35 |
2828

2929
## Providers
3030

31-
No providers.
31+
| Name | Version |
32+
|------|---------|
33+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.35 |
3234

3335
## Modules
3436

@@ -40,7 +42,9 @@ No providers.
4042

4143
## Resources
4244

43-
No resources.
45+
| Name | Type |
46+
|------|------|
47+
| [aws_cloudwatch_log_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
4448

4549
## Inputs
4650

examples/complete/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ module "prometheus" {
1515
source = "../.."
1616

1717
workspace_alias = local.name
18+
logging_configuration = {
19+
log_group_arn = aws_cloudwatch_log_group.this.arn
20+
}
1821

1922
alert_manager_definition = <<-EOT
2023
alertmanager_config: |
@@ -59,3 +62,10 @@ module "default" {
5962

6063
workspace_alias = "${local.name}-default"
6164
}
65+
66+
################################################################################
67+
# Supporting Resources
68+
################################################################################
69+
resource "aws_cloudwatch_log_group" "this" {
70+
name = "example-aws-managed-service-prometheus-complete"
71+
}

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 = ">= 4.1"
7+
version = ">= 4.35"
88
}
99
}
1010
}

main.tf

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
workspace_id = var.create_workspace ? aws_prometheus_workspace.this[0].id : var.workspace_id
2+
workspace_id = var.create && var.create_workspace ? aws_prometheus_workspace.this[0].id : var.workspace_id
33
}
44

55
################################################################################
@@ -10,7 +10,16 @@ resource "aws_prometheus_workspace" "this" {
1010
count = var.create && var.create_workspace ? 1 : 0
1111

1212
alias = var.workspace_alias
13-
tags = var.tags
13+
14+
dynamic "logging_configuration" {
15+
for_each = length(var.logging_configuration) > 0 ? [var.logging_configuration] : []
16+
17+
content {
18+
log_group_arn = logging_configuration.value.log_group_arn
19+
}
20+
}
21+
22+
tags = var.tags
1423
}
1524

1625
################################################################################

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ variable "workspace_alias" {
3232
default = null
3333
}
3434

35+
variable "logging_configuration" {
36+
description = "The logging configuration of the prometheus workspace."
37+
type = map(string)
38+
default = {}
39+
}
40+
3541
################################################################################
3642
# Alert Manager Definition
3743
################################################################################

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 = ">= 4.1"
7+
version = ">= 4.35"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)