-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
70 lines (63 loc) · 2.17 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#####################################################################################
# Terraform module examples are meant to show an _example_ on how to use a module
# per use-case. The code below should not be copied directly but referenced in order
# to build your own root module that invokes this module
#####################################################################################
locals {
monitors = [
{
name = "AWS Service Cost Anomaly Monitor"
monitor_type = "DIMENSIONAL"
monitor_dimension = "SERVICE"
notify = {
frequency = "IMMEDIATE"
threshold_expression = [
{
and = {
dimension = {
key = "ANOMALY_TOTAL_IMPACT_ABSOLUTE"
match_options = ["GREATER_THAN_OR_EQUAL"]
values = ["100"]
}
}
},
{
and = {
dimension = {
key = "ANOMALY_TOTAL_IMPACT_PERCENTAGE"
match_options = ["GREATER_THAN_OR_EQUAL"]
values = ["50"]
}
}
}
]
}
}
]
}
## Read the secret for aws secrets manager
data "aws_secretsmanager_secret" "notification" {
name = var.notification_secret_name
}
## Retrieve the current version of the secret
data "aws_secretsmanager_secret_version" "notification" {
secret_id = data.aws_secretsmanager_secret.notification.id
}
module "cost_anomaly_detection" {
source = "../../"
monitors = local.monitors
sns_topic_name = "this-is-an-existing-sns-topic"
tags = var.tags
notifications = {
email = {
addresses = var.notification_email_addresses
}
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
}
}
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
}