Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: notifications sa-251 teams and sa-228 enrichmenbt #9

Merged
merged 7 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 35 additions & 53 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion examples/budgets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ module "budgets" {
addresses = var.notification_emails
}
slack = {
channel = jsondecode(data.aws_secretsmanager_secret_version.notification.secret_string).channel
webhook_url = jsondecode(data.aws_secretsmanager_secret_version.notification.secret_string).webhook_url
}
}
tags = var.tags
accounts_id_to_name = {
"1234567890" = "mgmt"
}
}
8 changes: 4 additions & 4 deletions modules/budgets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ module "budgets" {
addresses = var.notification_emails
},
slack = {
channel = jsondecode(data.aws_secretsmanager_secret_version.slack.secret_string).channel
webhook_url = jsondecode(data.aws_secretsmanager_secret_version.slack.secret_string).webhook_url
}
}
Expand Down Expand Up @@ -99,13 +98,13 @@ The `terraform-docs` utility is used to generate this README. Follow the below s

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

## Modules

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

## Resources

Expand All @@ -117,9 +116,10 @@ The `terraform-docs` utility is used to generate this README. Follow the below s

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <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> channel = optional(string, null)<br> lambda_name = optional(string, "budget-notifications")<br> secret_name = optional(string, null)<br> username = optional(string, ":aws: AWS Budgets")<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_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_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
2 changes: 0 additions & 2 deletions modules/budgets/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ locals {

## If enabled, this will be the configuration for the slack notification
slack_configuration = local.enable_slack ? {
channel = var.notifications.slack.channel
lambda_name = var.notifications.slack.lambda_name
secret_name = var.notifications.slack.secret_name
username = var.notifications.slack.username
webhook_url = var.notifications.slack.webhook_url
} : null
}
12 changes: 7 additions & 5 deletions modules/budgets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
## Provision the SNS topic for the budgets if required and notifications
module "notifications" {
source = "appvia/notifications/aws"
version = "0.1.4"
version = "1.0.1"

allowed_aws_services = [
"budgets.amazonaws.com",
"lambda.amazonaws.com",
]
create_sns_topic = var.create_sns_topic
sns_topic_name = var.sns_topic_name
slack = local.slack_configuration
tags = var.tags
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
}

## Iterate over the budgets and provision them
Expand Down
7 changes: 5 additions & 2 deletions modules/budgets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ variable "notifications" {
addresses = list(string)
}), null)
slack = optional(object({
channel = optional(string, null)
lambda_name = optional(string, "budget-notifications")
secret_name = optional(string, null)
username = optional(string, ":aws: AWS Budgets")
webhook_url = optional(string, null)
}), null)
teams = optional(object({
Expand All @@ -87,3 +85,8 @@ variable "tags" {
type = map(string)
default = {}
}

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)
}
7 changes: 4 additions & 3 deletions modules/team-budgets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

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

## Modules

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

## Resources
Expand All @@ -30,7 +30,8 @@

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <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> channel = string<br> webhook_url = string<br> }), null)<br> teams = optional(object({<br> webhook_url = string<br> }), null)<br> })<br> }))</pre> | `[]` | no |
| <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_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
Loading