hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.11k forks source link

[Bug]: No option to eliminate fixed budget limit while using auto_adjust_data #28981

Open rito-sixt opened 1 year ago

rito-sixt commented 1 year ago

Terraform Core Version

1.1.7

AWS Provider Version

4.38.0

Affected Resource(s)

aws_budgets_budget

Expected Behavior

While configuring an auto adjusting budget, the fixed limit_amount becomes irrelevant. The current problem is that if we configure a budget with a auto_adjust_data block, for successive applies, Terraform keeps prompting that there was a change outside of Terraform, and hence wants me to sync the state back.

Actual Behavior

Ideally, while configuring an auto-adjusting budget does not need a fixed limit at all, and the budget amount can be excluded from Terraform altogether.

Relevant Error/Panic Output Snippet

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # module.budgets_and_alerts.aws_budgets_budget.backups-budget has changed
  ~ resource "aws_budgets_budget" "backups-budget" {
        id                = "402830816788:budget-backup-monthly"
      ~ limit_amount      = "0.0" -> "1763.74"
        name              = "budget-backup-monthly"
        # (8 unchanged attributes hidden)

      ~ auto_adjust_data {
          ~ last_auto_adjust_time = "0001-01-01T00:00:00Z" -> "2023-01-19T12:45:01Z"
            # (1 unchanged attribute hidden)

          ~ historical_options {
              ~ lookback_available_periods = 0 -> 3
                # (1 unchanged attribute hidden)
            }
        }

        # (3 unchanged blocks hidden)
    }

Terraform Configuration Files

resource "aws_budgets_budget" "s3-budget" {
  name         = "budget-s3-monthly"
  budget_type  = "COST"
  limit_amount = "1200"
  limit_unit   = "USD"
  time_unit    = "MONTHLY"

  cost_filter {
    name   = "Service"
    values = [
      "Amazon Simple Storage Service",
    ]
  }

  notification {
    comparison_operator       = "GREATER_THAN"
    threshold                 = 150
    threshold_type            = "PERCENTAGE"
    notification_type         = "FORECASTED"
    subscriber_sns_topic_arns = [aws_sns_topic.platform-updates.arn]
  }

  auto_adjust_data {
    auto_adjust_type = "HISTORICAL"
    historical_options {
      budget_adjustment_period = 3
    }
  }

  depends_on = [
    aws_sns_topic.platform-updates
  ]
}

Steps to Reproduce

  1. terraform apply on the above mentioned configuration block
  2. Successive terraform plan commands indicate that the budgets were changed out of Terraform, which is indeed true, but quite irrelevant and would be cumbersome to maintain

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes, if we can agree on a solution.

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

ckdake commented 1 year ago

As a workaround, this keeps plan/apply clean:

resource "aws_budgets_budget" "tenant_auto_adjust" {

  #[...]

  lifecycle {
    ignore_changes = [
      limit_amount
    ]
  }
}