From ff16b9a310ea5c124bcceda4334cb682f0a0ebf8 Mon Sep 17 00:00:00 2001 From: Priyesh Mistry Date: Mon, 27 Jan 2025 13:49:00 +0000 Subject: [PATCH 1/4] chore: update module version usage --- .gitignore | 1 + main.tf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8cdcd84..435eccb 100755 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ terraform.rc # Other .DS_Store todo.md +.idea # Ignore vim swap files *.swp diff --git a/main.tf b/main.tf index 2e5bf5f..428a7bd 100644 --- a/main.tf +++ b/main.tf @@ -3,7 +3,7 @@ module "notifications" { count = var.enable_notification_creation ? 1 : 0 source = "appvia/notifications/aws" - version = "1.1.0" + version = "2.0.0" allowed_aws_services = ["budgets.amazonaws.com", "costalerts.amazonaws.com", "lambda.amazonaws.com"] create_sns_topic = local.enable_sns_topic_creation From dd5b0a63a0584ab6d701e54fa7038c1310afc9c8 Mon Sep 17 00:00:00 2001 From: Priyesh Mistry Date: Thu, 30 Jan 2025 15:37:15 +0000 Subject: [PATCH 2/4] chore: update account id variable --- main.tf | 2 +- variables.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 428a7bd..17014d1 100644 --- a/main.tf +++ b/main.tf @@ -12,7 +12,7 @@ module "notifications" { slack = local.slack sns_topic_name = var.sns_topic_name tags = var.tags - accounts_id_to_name = var.accounts_id_to_name + accounts_id_to_name_parameter_arn = var.accounts_id_to_name_parameter_arn identity_center_start_url = var.identity_center_start_url identity_center_role = var.identity_center_role } diff --git a/variables.tf b/variables.tf index 975bbd4..f7f6e2c 100644 --- a/variables.tf +++ b/variables.tf @@ -67,8 +67,8 @@ variable "tags" { type = map(string) } -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" +variable "accounts_id_to_name_parameter_arn" { + description = "The ARN of your parameter containing the your account ID to name mapping. This ARN will be attached to lambda execution role as a resource, therefore a valid resource must exist. e.g 'arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts_id_to_name_mapping' to enable the lambda retrieve values from ssm." type = map(string) default = null } From 9f06f47dfc89fb36e9db1f9d5a64fa7e1ad4ac3d Mon Sep 17 00:00:00 2001 From: Priyesh Mistry Date: Thu, 30 Jan 2025 15:49:43 +0000 Subject: [PATCH 3/4] chore: update account id variable usage --- examples/basic/main.tf | 4 +--- examples/existing_sns/main.tf | 4 +--- variables.tf | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 5fd655e..6734183 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -82,9 +82,7 @@ module "cost_anomaly_detection" { } } tags = var.tags - accounts_id_to_name = { - "1234567890" = "mgmt" - } + accounts_id_to_name_parameter_arn = "arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts_id_to_name_mapping" identity_center_start_url = null identity_center_role = null } diff --git a/examples/existing_sns/main.tf b/examples/existing_sns/main.tf index 0fcde12..45a111a 100644 --- a/examples/existing_sns/main.tf +++ b/examples/existing_sns/main.tf @@ -64,9 +64,7 @@ module "cost_anomaly_detection" { } } - accounts_id_to_name = { - "1234567890" = "mgmt" - } + accounts_id_to_name_parameter_arn = "arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts_id_to_name_mapping" identity_center_start_url = null identity_center_role = null } diff --git a/variables.tf b/variables.tf index f7f6e2c..441256e 100644 --- a/variables.tf +++ b/variables.tf @@ -69,7 +69,7 @@ variable "tags" { variable "accounts_id_to_name_parameter_arn" { description = "The ARN of your parameter containing the your account ID to name mapping. This ARN will be attached to lambda execution role as a resource, therefore a valid resource must exist. e.g 'arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts_id_to_name_mapping' to enable the lambda retrieve values from ssm." - type = map(string) + type = string default = null } From c10c2d888d5641977328880ef7839daa1865e55a Mon Sep 17 00:00:00 2001 From: Priyesh Mistry Date: Thu, 30 Jan 2025 15:58:59 +0000 Subject: [PATCH 4/4] chore: fmt and docs --- README.md | 2 +- examples/basic/main.tf | 6 +++--- examples/existing_sns/main.tf | 4 ++-- main.tf | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f6362b9..632f854 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The `terraform-docs` utility is used to generate this README. Follow the below s | [monitors](#input\_monitors) | A collection of cost anomaly monitors to create |
list(object({
name = string
# The name of the monitor
monitor_type = optional(string, "DIMENSIONAL")
# The type of monitor to create
monitor_dimension = optional(string, "DIMENSIONAL")
# The dimension to monitor
monitor_specification = optional(string, null)
# The specification to monitor
notify = optional(object({
frequency = string
# The frequency of notifications
threshold_expression = optional(any, null)
# The threshold expression to use for notifications
}), {
frequency = "DAILY"
})
}))
| n/a | yes | | [notifications](#input\_notifications) | The configuration of the notification |
object({
email = optional(object({
addresses = list(string)
}), null)
slack = optional(object({
secret_name = optional(string, null)
# An optional secret name in the AWS Secrets Manager, containing this information
lambda_name = optional(string, "cost-anomaly-notification")
# The name of the Lambda function to use for notifications
webhook_url = optional(string, null)
# The URL of the Slack webhook to use for notifications, required if secret_name is not provided
}), null)
})
| n/a | yes | | [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | n/a | yes | -| [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 | +| [accounts\_id\_to\_name\_parameter\_arn](#input\_accounts\_id\_to\_name\_parameter\_arn) | The ARN of your parameter containing the your account ID to name mapping. This ARN will be attached to lambda execution role as a resource, therefore a valid resource must exist. e.g 'arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts\_id\_to\_name\_mapping' to enable the lambda retrieve values from ssm. | `string` | `null` | no | | [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 | | [enable\_sns\_topic\_creation](#input\_enable\_sns\_topic\_creation) | Indicates whether to create an SNS topic within this module | `bool` | `true` | no | | [identity\_center\_role](#input\_identity\_center\_role) | The name of the role to use when redirecting through Identity Center | `string` | `null` | no | diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 6734183..afef5c8 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -81,8 +81,8 @@ module "cost_anomaly_detection" { webhook_url = "https://hooks.slack.com/services/FAKE/URL" } } - tags = var.tags + tags = var.tags accounts_id_to_name_parameter_arn = "arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts_id_to_name_mapping" - identity_center_start_url = null - identity_center_role = null + identity_center_start_url = null + identity_center_role = null } diff --git a/examples/existing_sns/main.tf b/examples/existing_sns/main.tf index 45a111a..d4409ff 100644 --- a/examples/existing_sns/main.tf +++ b/examples/existing_sns/main.tf @@ -65,6 +65,6 @@ module "cost_anomaly_detection" { } accounts_id_to_name_parameter_arn = "arn:aws:ssm:eu-west-2:0123456778:parameter/myorg/configmaps/accounts_id_to_name_mapping" - identity_center_start_url = null - identity_center_role = null + identity_center_start_url = null + identity_center_role = null } diff --git a/main.tf b/main.tf index 17014d1..bd7b7f1 100644 --- a/main.tf +++ b/main.tf @@ -5,16 +5,16 @@ module "notifications" { source = "appvia/notifications/aws" version = "2.0.0" - allowed_aws_services = ["budgets.amazonaws.com", "costalerts.amazonaws.com", "lambda.amazonaws.com"] - create_sns_topic = local.enable_sns_topic_creation - email = local.email - enable_slack = local.enable_slack - slack = local.slack - sns_topic_name = var.sns_topic_name - tags = var.tags - accounts_id_to_name_parameter_arn = var.accounts_id_to_name_parameter_arn - identity_center_start_url = var.identity_center_start_url - identity_center_role = var.identity_center_role + allowed_aws_services = ["budgets.amazonaws.com", "costalerts.amazonaws.com", "lambda.amazonaws.com"] + create_sns_topic = local.enable_sns_topic_creation + email = local.email + enable_slack = local.enable_slack + slack = local.slack + sns_topic_name = var.sns_topic_name + tags = var.tags + accounts_id_to_name_parameter_arn = var.accounts_id_to_name_parameter_arn + identity_center_start_url = var.identity_center_start_url + identity_center_role = var.identity_center_role } ## Provision the cost anomaly detection for services