Skip to content

Commit

Permalink
Support link configurations for oam-link (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 authored Jul 15, 2024
1 parent b4a31ab commit f9c5219
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
10 changes: 7 additions & 3 deletions modules/cloudwatch-oam-link/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ This module creates following resources.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.63 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.8 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.58 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.51.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.58.0 |

## Modules

Expand All @@ -36,6 +36,8 @@ This module creates following resources.
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the CloudWatch OAM link. | `string` | n/a | yes |
| <a name="input_sink"></a> [sink](#input\_sink) | (Required) The ARN of the sink to use to create this link. | `string` | n/a | yes |
| <a name="input_account_label"></a> [account\_label](#input\_account\_label) | (Optional) A label to help identify your source account. In the monitoring account, the account label is displayed with data from that source account. The account label is displayed in charts and search experiences to help you identify account context. Support use following template variables. Defaults to `$AccountName`.<br> - `$AccountName`: Account name used to identify accounts.<br> - `$AccountEmail`: Email address used to identify accounts. (i.e. name@amazon.com)<br> - `$AccountEmailNoDomain`: Email address without domain (i.e. without @amazon.com) used to identify accounts. | `string` | `"$AccountName"` | no |
| <a name="input_log_group_configuration"></a> [log\_group\_configuration](#input\_log\_group\_configuration) | (Optional) A configuration for filtering which log groups are to send log events from the source account to the monitoring account. `log_group_configuration` as defined below.<br> (Optional) `filter` - Filter string that specifies which log groups are to share their log events with the monitoring account. | <pre>object({<br> filter = optional(string, "")<br> })</pre> | `{}` | no |
| <a name="input_metric_configuration"></a> [metric\_configuration](#input\_metric\_configuration) | (Optional) A configuration for filtering which metric namespaces are to be shared from the source account to the monitoring account. `log_group_configuration` as defined below.<br> (Optional) `filter` - Filter string that specifies which metrics are to be shared with the monitoring account. | <pre>object({<br> filter = optional(string, "")<br> })</pre> | `{}` | no |
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |
Expand All @@ -50,6 +52,8 @@ This module creates following resources.
| <a name="output_account_label"></a> [account\_label](#output\_account\_label) | A label to help identify your source account. |
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the CloudWatch OAM link. |
| <a name="output_id"></a> [id](#output\_id) | The ID of the CloudWatch OAM link. |
| <a name="output_log_group_configuration"></a> [log\_group\_configuration](#output\_log\_group\_configuration) | A configuration for filtering which log groups are to send log events from the source account to the monitoring account. |
| <a name="output_metric_configuration"></a> [metric\_configuration](#output\_metric\_configuration) | A configuration for filtering which metric namespaces are to be shared from the source account to the monitoring account. |
| <a name="output_name"></a> [name](#output\_name) | The name of CloudWatch OAM link. |
| <a name="output_sink"></a> [sink](#output\_sink) | The information of the sink for this link. |
| <a name="output_telemetry_types"></a> [telemetry\_types](#output\_telemetry\_types) | A set of the telemetry types that the source account shares with the monitoring account. |
Expand Down
21 changes: 21 additions & 0 deletions modules/cloudwatch-oam-link/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ resource "aws_oam_link" "this" {
label_template = var.account_label
resource_types = var.telemetry_types

dynamic "link_configuration" {
for_each = (var.log_group_configuration.filter != "" || var.metric_configuration.filter != "") ? ["go"] : []

content {
dynamic "log_group_configuration" {
for_each = var.log_group_configuration.filter != "" ? [var.log_group_configuration] : []

content {
filter = log_group_configuration.value.filter
}
}
dynamic "metric_configuration" {
for_each = var.metric_configuration.filter != "" ? [var.metric_configuration] : []

content {
filter = metric_configuration.value.filter
}
}
}
}

tags = merge(
{
"Name" = local.metadata.name
Expand Down
10 changes: 10 additions & 0 deletions modules/cloudwatch-oam-link/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ output "telemetry_types" {
description = "A set of the telemetry types that the source account shares with the monitoring account."
value = aws_oam_link.this.resource_types
}

output "log_group_configuration" {
description = "A configuration for filtering which log groups are to send log events from the source account to the monitoring account."
value = var.log_group_configuration
}

output "metric_configuration" {
description = "A configuration for filtering which metric namespaces are to be shared from the source account to the monitoring account."
value = var.metric_configuration
}
24 changes: 24 additions & 0 deletions modules/cloudwatch-oam-link/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ variable "telemetry_types" {
}
}

variable "log_group_configuration" {
description = <<EOF
(Optional) A configuration for filtering which log groups are to send log events from the source account to the monitoring account. `log_group_configuration` as defined below.
(Optional) `filter` - Filter string that specifies which log groups are to share their log events with the monitoring account.
EOF
type = object({
filter = optional(string, "")
})
default = {}
nullable = false
}

variable "metric_configuration" {
description = <<EOF
(Optional) A configuration for filtering which metric namespaces are to be shared from the source account to the monitoring account. `log_group_configuration` as defined below.
(Optional) `filter` - Filter string that specifies which metrics are to be shared with the monitoring account.
EOF
type = object({
filter = optional(string, "")
})
default = {}
nullable = false
}

variable "tags" {
description = "(Optional) A map of tags to add to all resources."
type = map(string)
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudwatch-oam-link/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.6"
required_version = ">= 1.8"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.63"
version = ">= 5.58"
}
}
}
4 changes: 2 additions & 2 deletions modules/cloudwatch-oam-sink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ This module creates following resources.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.63 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.8 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.58 |

## Providers

Expand Down
4 changes: 2 additions & 2 deletions modules/cloudwatch-oam-sink/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.6"
required_version = ">= 1.8"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.63"
version = ">= 5.58"
}
}
}

0 comments on commit f9c5219

Please sign in to comment.