Skip to content

Commit

Permalink
feat: sa-384 latest notifications (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
wozzer72 authored Sep 13, 2024
1 parent cd189b7 commit 2cc695b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
4 changes: 3 additions & 1 deletion modules/budgets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The `terraform-docs` utility is used to generate this README. Follow the below s

| Name | Source | Version |
|------|--------|---------|
| <a name="module_notifications"></a> [notifications](#module\_notifications) | appvia/notifications/aws | 1.0.3 |
| <a name="module_notifications"></a> [notifications](#module\_notifications) | appvia/notifications/aws | 1.0.4 |

## Resources

Expand All @@ -119,6 +119,8 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
| <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)` | n/a | yes |
| <a name="input_budgets"></a> [budgets](#input\_budgets) | A collection of budgets to provision | <pre>list(object({<br> name = string<br> budget_type = optional(string, "COST")<br> limit_amount = optional(string, "100.0")<br> limit_unit = optional(string, "PERCENTAGE")<br> time_unit = optional(string, "MONTHLY")<br><br> notification = optional(object({<br> comparison_operator = string<br> threshold = number<br> threshold_type = string<br> notification_type = string<br> }), null)<br><br> auto_adjust_data = optional(list(object({<br> auto_adjust_type = string<br> })), [])<br><br> cost_filter = optional(list(object({<br> name = string<br> values = list(string)<br> })), [])<br><br> cost_types = optional(object({<br> include_credit = optional(bool, false)<br> include_discount = optional(bool, false)<br> include_other_subscription = optional(bool, false)<br> include_recurring = optional(bool, false)<br> include_refund = optional(bool, false)<br> include_subscription = optional(bool, false)<br> include_support = optional(bool, false)<br> include_tax = optional(bool, false)<br> include_upfront = optional(bool, false)<br> use_blended = optional(bool, false)<br> }), {<br> include_credit = false<br> include_discount = false<br> include_other_subscription = false<br> include_recurring = false<br> include_refund = false<br> include_subscription = true<br> include_support = false<br> include_tax = false<br> include_upfront = false<br> use_blended = false<br> })<br> }))</pre> | `[]` | no |
| <a name="input_create_sns_topic"></a> [create\_sns\_topic](#input\_create\_sns\_topic) | A flag to determine if the SNS topic should be created | `bool` | `true` | no |
| <a name="input_identity_center_role"></a> [identity\_center\_role](#input\_identity\_center\_role) | The name of the role to use when redirecting through Identity Center | `string` | `null` | no |
| <a name="input_identity_center_start_url"></a> [identity\_center\_start\_url](#input\_identity\_center\_start\_url) | The start URL of your Identity Center instance | `string` | `null` | no |
| <a name="input_notifications"></a> [notifications](#input\_notifications) | The configuration as to how the budget notifications should be sent | <pre>object({<br> email = optional(object({<br> addresses = list(string)<br> }), null)<br> slack = optional(object({<br> lambda_name = optional(string, "budget-notifications")<br> secret_name = optional(string, null)<br> webhook_url = optional(string, null)<br> }), null)<br> teams = optional(object({<br> webhook_url = string<br> }), null)<br> })</pre> | n/a | yes |
| <a name="input_sns_topic_name"></a> [sns\_topic\_name](#input\_sns\_topic\_name) | The name of the SNS topic to create for budget notifications | `string` | `"budget-notifications"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
Expand Down
16 changes: 9 additions & 7 deletions modules/budgets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
## Provision the SNS topic for the budgets if required and notifications
module "notifications" {
source = "appvia/notifications/aws"
version = "1.0.3"
version = "1.0.4"

allowed_aws_services = [
"budgets.amazonaws.com",
"lambda.amazonaws.com",
]
create_sns_topic = var.create_sns_topic
sns_topic_name = var.sns_topic_name
enable_slack = local.enable_slack
slack = local.slack_configuration
tags = var.tags
accounts_id_to_name = var.accounts_id_to_name
create_sns_topic = var.create_sns_topic
sns_topic_name = var.sns_topic_name
enable_slack = local.enable_slack
slack = local.slack_configuration
tags = var.tags
accounts_id_to_name = var.accounts_id_to_name
identity_center_start_url = var.identity_center_start_url
identity_center_role = var.identity_center_role
}

## Iterate over the budgets and provision them
Expand Down
12 changes: 12 additions & 0 deletions modules/budgets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,15 @@ variable "accounts_id_to_name" {
description = "A mapping of account id and account name - used by notification lamdba to map an account ID to a human readable name"
type = map(string)
}

variable "identity_center_start_url" {
description = "The start URL of your Identity Center instance"
type = string
default = null
}

variable "identity_center_role" {
description = "The name of the role to use when redirecting through Identity Center"
type = string
default = null
}
4 changes: 3 additions & 1 deletion modules/team-budgets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

| Name | Source | Version |
|------|--------|---------|
| <a name="module_slack_notfications"></a> [slack\_notfications](#module\_slack\_notfications) | appvia/notifications/aws | 1.0.3 |
| <a name="module_slack_notfications"></a> [slack\_notfications](#module\_slack\_notfications) | appvia/notifications/aws | 1.0.4 |
| <a name="module_sns"></a> [sns](#module\_sns) | terraform-aws-modules/sns/aws | v6.0.1 |

## Resources
Expand All @@ -32,6 +32,8 @@
|------|-------------|------|---------|:--------:|
| <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)` | n/a | yes |
| <a name="input_budgets"></a> [budgets](#input\_budgets) | A collection of product or team budgets | <pre>list(object({<br> amount = number<br> name = string<br> notification_type = optional(string, "ACTUAL")<br> threshold = optional(number, 100)<br> threshold_type = optional(string, "PERCENTAGE")<br> time_unit = optional(string, "MONTHLY")<br><br> cost_filter = optional(list(object({<br> name = string<br> values = list(string)<br> })), [])<br><br> cost_types = optional(object({<br> include_credit = optional(bool, false)<br> include_discount = optional(bool, false)<br> include_other_subscription = optional(bool, false)<br> include_recurring = optional(bool, false)<br> include_refund = optional(bool, false)<br> include_subscription = optional(bool, false)<br> include_support = optional(bool, false)<br> include_tax = optional(bool, false)<br> include_upfront = optional(bool, false)<br> use_blended = optional(bool, false)<br> }), {<br> include_credit = false<br> include_discount = false<br> include_other_subscription = false<br> include_recurring = false<br> include_refund = false<br> include_subscription = false<br> include_support = false<br> include_tax = false<br> include_upfront = false<br> use_blended = false<br> })<br><br> notification = object({<br> email = optional(object({<br> addresses = list(string)<br> }), null)<br> slack = optional(object({<br> webhook_url = string<br> }), null)<br> teams = optional(object({<br> webhook_url = string<br> }), null)<br> })<br> }))</pre> | `[]` | no |
| <a name="input_identity_center_role"></a> [identity\_center\_role](#input\_identity\_center\_role) | The name of the role to use when redirecting through Identity Center | `string` | `null` | no |
| <a name="input_identity_center_start_url"></a> [identity\_center\_start\_url](#input\_identity\_center\_start\_url) | The start URL of your Identity Center instance | `string` | `null` | no |
| <a name="input_sns_topic_arn"></a> [sns\_topic\_arn](#input\_sns\_topic\_arn) | A SNS topic which all notifications are sent to | `string` | `""` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to apply to the resources | `map(string)` | `{}` | no |

Expand Down
10 changes: 6 additions & 4 deletions modules/team-budgets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ module "slack_notfications" {
for_each = { for budget in var.budgets : budget.name => budget if budget.slack_notification.slack != null }

source = "appvia/notifications/aws"
version = "1.0.3"
version = "1.0.4"

create_sns_topic = false
enable_slack = true
slack = {
webhook_url = each.value.slack_notification.slack_webhook_url
lambda_name = format("team-budgets-notifications-%s", md5(each.value.name))
}
sns_topic_name = module.sns[each.key].topic_name
tags = var.tags
accounts_id_to_name = var.accounts_id_to_name
sns_topic_name = module.sns[each.key].topic_name
tags = var.tags
accounts_id_to_name = var.accounts_id_to_name
identity_center_start_url = var.identity_center_start_url
identity_center_role = var.identity_center_role
}
12 changes: 12 additions & 0 deletions modules/team-budgets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,15 @@ variable "accounts_id_to_name" {
description = "A mapping of account id and account name - used by notification lamdba to map an account ID to a human readable name"
type = map(string)
}

variable "identity_center_start_url" {
description = "The start URL of your Identity Center instance"
type = string
default = null
}

variable "identity_center_role" {
description = "The name of the role to use when redirecting through Identity Center"
type = string
default = null
}

0 comments on commit 2cc695b

Please sign in to comment.