Skip to content

Commit 6fffab6

Browse files
authoredSep 11, 2024
feat/SA-251: upgrading to latest notifications module (#26)
* feat: bumping to use new notifications module
1 parent 0a42d36 commit 6fffab6

File tree

8 files changed

+66
-40
lines changed

8 files changed

+66
-40
lines changed
 

‎.terraform.lock.hcl

+45-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
5555

5656
| Name | Source | Version |
5757
|------|--------|---------|
58-
| <a name="module_notifications"></a> [notifications](#module\_notifications) | appvia/notifications/aws | 0.1.7 |
58+
| <a name="module_notifications"></a> [notifications](#module\_notifications) | appvia/notifications/aws | 1.0.1 |
5959

6060
## Resources
6161

@@ -69,8 +69,9 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
6969
| Name | Description | Type | Default | Required |
7070
|------|-------------|------|---------|:--------:|
7171
| <a name="input_monitors"></a> [monitors](#input\_monitors) | A collection of cost anomaly monitors to create | <pre>list(object({<br> name = string<br> # The name of the monitor <br> monitor_type = optional(string, "DIMENSIONAL")<br> # The type of monitor to create <br> monitor_dimension = optional(string, "DIMENSIONAL")<br> # The dimension to monitor<br> monitor_specification = optional(string, null)<br> # The specification to monitor <br> notify = optional(object({<br> frequency = string<br> # The frequency of notifications<br> threshold_expression = optional(any, null)<br> # The threshold expression to use for notifications<br> }), {<br> frequency = "DAILY"<br> })<br> }))</pre> | n/a | yes |
72-
| <a name="input_notifications"></a> [notifications](#input\_notifications) | The configuration of the notification | <pre>object({<br> email = optional(object({<br> addresses = list(string)<br> }), null)<br> slack = optional(object({<br> channel = optional(string, null)<br> # The channel name for notifications, required if secret_name is not provided<br> secret_name = optional(string, null)<br> # An optional secret name in the AWS Secrets Manager, containing this information <br> lambda_name = optional(string, "cost-anomaly-notification")<br> # The name of the Lambda function to use for notifications <br> username = optional(string, "AWS Cost Anomaly Detection")<br> # The username to use for notifications<br> webhook_url = optional(string, null)<br> # The URL of the Slack webhook to use for notifications, required if secret_name is not provided<br> }), null)<br> })</pre> | n/a | yes |
72+
| <a name="input_notifications"></a> [notifications](#input\_notifications) | The configuration of the notification | <pre>object({<br> email = optional(object({<br> addresses = list(string)<br> }), null)<br> slack = optional(object({<br> secret_name = optional(string, null)<br> # An optional secret name in the AWS Secrets Manager, containing this information <br> lambda_name = optional(string, "cost-anomaly-notification")<br> # The name of the Lambda function to use for notifications <br> webhook_url = optional(string, null)<br> # The URL of the Slack webhook to use for notifications, required if secret_name is not provided<br> }), null)<br> })</pre> | n/a | yes |
7373
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | n/a | yes |
74+
| <a name="input_accounts_id_to_name"></a> [accounts\_id\_to\_name](#input\_accounts\_id\_to\_name) | A mapping of account id and account name - used by notification lamdba to map an account ID to a human readable name | `map(string)` | `null` | no |
7475
| <a name="input_enable_notification_creation"></a> [enable\_notification\_creation](#input\_enable\_notification\_creation) | Indicates whether to create a notification lambda stack, default is true, but useful to toggle if using existing resources | `bool` | `true` | no |
7576
| <a name="input_enable_sns_topic_creation"></a> [enable\_sns\_topic\_creation](#input\_enable\_sns\_topic\_creation) | Indicates whether to create an SNS topic within this module | `bool` | `true` | no |
7677
| <a name="input_sns_topic_arn"></a> [sns\_topic\_arn](#input\_sns\_topic\_arn) | The ARN of an existing SNS topic for notifications | `string` | `null` | no |

‎examples/basic/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,7 @@ module "cost_anomaly_detection" {
8282
}
8383
}
8484
tags = var.tags
85+
accounts_id_to_name = {
86+
"1234567890" = "mgmt"
87+
}
8588
}

‎examples/existing_sns/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
| Name | Version |
1313
|------|---------|
14-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0.0 |
14+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.65.0 |
1515

1616
## Modules
1717

@@ -30,8 +30,8 @@
3030

3131
| Name | Description | Type | Default | Required |
3232
|------|-------------|------|---------|:--------:|
33-
| <a name="input_notification_secret_name"></a> [notification\_secret\_name](#input\_notification\_secret\_name) | The name of the secret that contains the notification configuration | `string` | n/a | yes |
3433
| <a name="input_notification_email_addresses"></a> [notification\_email\_addresses](#input\_notification\_email\_addresses) | The list of email addresses to notify | `list(string)` | `[]` | no |
34+
| <a name="input_notification_secret_name"></a> [notification\_secret\_name](#input\_notification\_secret\_name) | The name of the secret that contains the notification configuration | `string` | n/a | yes |
3535
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to the resources | `map(string)` | `{}` | no |
3636

3737
## Outputs

‎examples/existing_sns/main.tf

+4
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ module "cost_anomaly_detection" {
6363
webhook_url = jsondecode(data.aws_secretsmanager_secret_version.notification.secret_string).webhook_url
6464
}
6565
}
66+
67+
accounts_id_to_name = {
68+
"1234567890" = "mgmt"
69+
}
6670
}

‎locals.tf

-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ locals {
1818

1919
## The configuration for slack notifications if enabled
2020
slack = local.enable_slack ? {
21-
channel = var.notifications.slack.channel
2221
lambda_name = var.notifications.slack.lambda_name
2322
secret_name = var.notifications.slack.secret_name
24-
username = var.notifications.slack.username
2523
webhook_url = var.notifications.slack.webhook_url
2624
} : null
2725
}

‎main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
module "notifications" {
44
count = var.enable_notification_creation ? 1 : 0
55
source = "appvia/notifications/aws"
6-
version = "0.1.7"
6+
version = "1.0.1"
77

88
allowed_aws_services = ["budgets.amazonaws.com", "costalerts.amazonaws.com", "lambda.amazonaws.com"]
99
create_sns_topic = local.enable_sns_topic_creation
1010
email = local.email
11+
enable_slack = local.enable_slack
1112
slack = local.slack
1213
sns_topic_name = var.sns_topic_name
1314
tags = var.tags
15+
accounts_id_to_name = var.accounts_id_to_name
1416
}
1517

1618
## Provision the cost anomaly detection for services

‎variables.tf

+6-4
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,10 @@ variable "notifications" {
4040
addresses = list(string)
4141
}), null)
4242
slack = optional(object({
43-
channel = optional(string, null)
44-
# The channel name for notifications, required if secret_name is not provided
4543
secret_name = optional(string, null)
4644
# An optional secret name in the AWS Secrets Manager, containing this information
4745
lambda_name = optional(string, "cost-anomaly-notification")
4846
# The name of the Lambda function to use for notifications
49-
username = optional(string, "AWS Cost Anomaly Detection")
50-
# The username to use for notifications
5147
webhook_url = optional(string, null)
5248
# The URL of the Slack webhook to use for notifications, required if secret_name is not provided
5349
}), null)
@@ -70,3 +66,9 @@ variable "tags" {
7066
description = "A map of tags to add to all resources"
7167
type = map(string)
7268
}
69+
70+
variable "accounts_id_to_name" {
71+
description = "A mapping of account id and account name - used by notification lamdba to map an account ID to a human readable name"
72+
type = map(string)
73+
default = null
74+
}

0 commit comments

Comments
 (0)
Please sign in to comment.