Skip to content

Commit 04f15ab

Browse files
committed
fix: some of the filters on the thresholds were not working
1 parent eed551b commit 04f15ab

File tree

3 files changed

+59
-17
lines changed

3 files changed

+59
-17
lines changed

.terraform-docs.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
formatter: markdown
2+
#header-from: .header.md
3+
settings:
4+
anchor: true
5+
color: true
6+
default: true
7+
escape: true
8+
html: true
9+
indent: 2
10+
required: true
11+
sensitive: true
12+
type: true
13+
lockfile: false
14+
15+
sort:
16+
enabled: true
17+
by: required
18+
19+
output:
20+
file: README.md
21+
mode: inject

examples/basic/main.tf

+29-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ locals {
1313
notify = {
1414
frequency = "IMMEDIATE"
1515
threshold_expression = [
16+
{
17+
dimension = {
18+
key = "ANOMALY_TOTAL_IMPACT_ABSOLUTE"
19+
match_options = ["GREATER_THAN_OR_EQUAL"]
20+
values = ["100"]
21+
}
22+
},
23+
{
24+
cost_category = {
25+
key = "Environment"
26+
match_options = ["EQUALS"]
27+
values = ["Development"]
28+
}
29+
},
30+
{
31+
tags = {
32+
key = "Environment"
33+
match_options = ["EQUALS"]
34+
values = ["Development"]
35+
}
36+
},
1637
{
1738
and = {
1839
dimension = {
@@ -38,14 +59,14 @@ locals {
3859
}
3960

4061
## Read the secret for aws secrets manager
41-
data "aws_secretsmanager_secret" "notification" {
42-
name = var.notification_secret_name
43-
}
62+
# data "aws_secretsmanager_secret" "notification" {
63+
# name = var.notification_secret_name
64+
#}
4465

4566
## Retrieve the current version of the secret
46-
data "aws_secretsmanager_secret_version" "notification" {
47-
secret_id = data.aws_secretsmanager_secret.notification.id
48-
}
67+
#data "aws_secretsmanager_secret_version" "notification" {
68+
# secret_id = data.aws_secretsmanager_secret.notification.id
69+
#}
4970

5071
module "cost_anomaly_detection" {
5172
source = "../../"
@@ -56,8 +77,8 @@ module "cost_anomaly_detection" {
5677
addresses = var.notification_email_addresses
5778
}
5879
slack = {
59-
channel = jsondecode(data.aws_secretsmanager_secret_version.notification.secret_string).channel
60-
webhook_url = jsondecode(data.aws_secretsmanager_secret_version.notification.secret_string).webhook_url
80+
channel = "myfakechannel"
81+
webhook_url = "https://hooks.slack.com/services/FAKE/URL"
6182
}
6283
}
6384
tags = var.tags

main.tf

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@ resource "aws_ce_anomaly_subscription" "this" {
3939
dynamic "dimension" {
4040
for_each = [for x in each.value.notify.threshold_expression : x if lookup(x, "dimension", null) != null]
4141
content {
42-
key = dimension.value.key
43-
match_options = dimension.value.match_options
44-
values = dimension.value.values
42+
key = dimension.value.dimension.key
43+
match_options = dimension.value.dimension.match_options
44+
values = dimension.value.dimension.values
4545
}
4646
}
4747

4848
dynamic "cost_category" {
4949
for_each = [for x in each.value.notify.threshold_expression : x if lookup(x, "cost_category", null) != null]
5050
content {
51-
key = cost_category.value.key
52-
match_options = cost_category.value.match_options
53-
values = cost_category.value.values
51+
key = cost_category.value.cost_category.key
52+
match_options = cost_category.value.cost_category.match_options
53+
values = cost_category.value.cost_category.values
5454
}
5555
}
5656

5757
dynamic "tags" {
5858
for_each = [for x in each.value.notify.threshold_expression : x if lookup(x, "tags", null) != null]
5959
content {
60-
key = tags.value.key
61-
match_options = tags.value.match_options
62-
values = tags.value.values
60+
key = tags.value.tags.key
61+
match_options = tags.value.tags.match_options
62+
values = tags.value.tags.values
6363
}
6464
}
6565

0 commit comments

Comments
 (0)