StratusGrid / terraform-aws-anomaly-detection-alerts

This module creates an AWS Cost Anomaly Detection monitor and subscription.
1 stars 3 forks source link

Error: Unsupported argument: An argument named "threshold" is not expected here. #11

Open purduemike opened 1 year ago

purduemike commented 1 year ago

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

  1. Terraform plan

Specifications

petarda3 commented 7 months ago

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