Error: Unsupported argument: An argument named "threshold" is not expected here.
purduemike opened this issue · 1 comments
Used the module this way:
module "aws_anomaly_detection_alerts" {
source = "StratusGrid/anomaly-detection-alerts/aws"
version = "3.0.0"
cost_threshold = 1000
subscription_email = "some-email@some-email-server.com"
input_tags = local.default_tags
}
Then ran terraform plan.
Expected Behavior
A successful TF plan.
Actual Behavior
Getting this error:
╷
│ Error: Unsupported argument
│
│ on .terraform/modules/aws_anomaly_detection_alerts/main.tf line 17, in resource "aws_ce_anomaly_subscription" "this":
│ 17: threshold = var.cost_threshold
│
│ An argument named "threshold" is not expected here.
╵
Steps to Reproduce the Problem
- Terraform plan
Specifications
- Version: 3.0
- Platform: Linux
- Subsystem:
This solution works for me and so it should also work for you. First thing was to update main.tf to use threshold expression like this (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ce_anomaly_subscription):
threshold_expression {
dimension {
key = "ANOMALY_TOTAL_IMPACT_ABSOLUTE"
values = [tostring(var.cost_threshold)]
match_options = ["GREATER_THAN_OR_EQUAL"]
}
}
Also you need to change value to use tostring
function in order to avoid the error considering set of strings. The above snippet should resolve all your problems