Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS_CE_COST_CATEGORY: be able to use nested operands like you can via aws api #30862

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/30862.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ce_cost_category: Allow up to 3 levels of `and`, not` and `or` operand nesting for the `rule` argument
```
12 changes: 8 additions & 4 deletions internal/service/ce/anomaly_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"github.com/hashicorp/terraform-provider-aws/names"
)

const (
anomalySubscriptionRootElementSchemaLevel = 2
)

// @SDKResource("aws_ce_anomaly_subscription", name="Anomaly Subscription")
// @Tags(identifierAttribute="id")
func resourceAnomalySubscription() *schema.Resource {
Expand Down Expand Up @@ -96,7 +100,7 @@ func resourceAnomalySubscription() *schema.Resource {
MaxItems: 1,
Computed: true,
Optional: true,
Elem: elemExpression(),
Elem: expressionElem(anomalySubscriptionRootElementSchemaLevel),
},
},

Expand Down Expand Up @@ -124,7 +128,7 @@ func resourceAnomalySubscriptionCreate(ctx context.Context, d *schema.ResourceDa
}

if v, ok := d.GetOk("threshold_expression"); ok {
input.AnomalySubscription.ThresholdExpression = expandCostExpression(v.([]interface{})[0].(map[string]interface{}))
input.AnomalySubscription.ThresholdExpression = expandExpression(v.([]interface{})[0].(map[string]interface{}))
}

output, err := conn.CreateAnomalySubscription(ctx, input)
Expand Down Expand Up @@ -160,7 +164,7 @@ func resourceAnomalySubscriptionRead(ctx context.Context, d *schema.ResourceData
d.Set("monitor_arn_list", subscription.MonitorArnList)
d.Set("name", subscription.SubscriptionName)
d.Set("subscriber", flattenSubscribers(subscription.Subscribers))
if err := d.Set("threshold_expression", []interface{}{flattenCostCategoryRuleExpression(subscription.ThresholdExpression)}); err != nil {
if err := d.Set("threshold_expression", []interface{}{flattenExpression(subscription.ThresholdExpression)}); err != nil {
return sdkdiag.AppendErrorf(diags, "setting threshold_expression: %s", err)
}

Expand Down Expand Up @@ -190,7 +194,7 @@ func resourceAnomalySubscriptionUpdate(ctx context.Context, d *schema.ResourceDa
}

if d.HasChange("threshold_expression") {
input.ThresholdExpression = expandCostExpression(d.Get("threshold_expression").([]interface{})[0].(map[string]interface{}))
input.ThresholdExpression = expandExpression(d.Get("threshold_expression").([]interface{})[0].(map[string]interface{}))
}

_, err := conn.UpdateAnomalySubscription(ctx, input)
Expand Down
Loading
Loading