@@ -77,6 +77,45 @@ func TestAccDatadogCostBudget_WithTagFilters(t *testing.T) {
7777 })
7878}
7979
80+ func TestAccDatadogCostBudget_Update (t * testing.T ) {
81+ t .Parallel ()
82+ ctx , providers , accProviders := testAccFrameworkMuxProviders (context .Background (), t )
83+ budgetName := uniqueEntityName (ctx , t )
84+ budgetNameUpdated := budgetName + "updated!"
85+
86+ resource .Test (t , resource.TestCase {
87+ PreCheck : func () { testAccPreCheck (t ) },
88+ ProtoV5ProviderFactories : accProviders ,
89+ CheckDestroy : testAccCheckDatadogCostBudgetDestroy (providers .frameworkProvider ),
90+ Steps : []resource.TestStep {
91+ {
92+ Config : testAccCheckDatadogCostBudgetBasic (budgetName ),
93+ Check : resource .ComposeTestCheckFunc (
94+ resource .TestCheckResourceAttr (
95+ "datadog_cost_budget.foo" , "name" , budgetName ),
96+ resource .TestCheckResourceAttrSet (
97+ "datadog_cost_budget.foo" , "id" ),
98+ resource .TestCheckResourceAttr (
99+ "datadog_cost_budget.foo" , "entries.0.amount" , "1000" ),
100+ ),
101+ },
102+ {
103+ Config : testAccCheckDatadogCostBudgetUpdated (budgetNameUpdated ),
104+ Check : resource .ComposeTestCheckFunc (
105+ resource .TestCheckResourceAttr (
106+ "datadog_cost_budget.foo" , "name" , budgetNameUpdated ),
107+ // The most important!!: ID should remain the same after update, so making sure the id is different between the 2 steps
108+ resource .TestCheckResourceAttrPair (
109+ "datadog_cost_budget.foo" , "id" ,
110+ "datadog_cost_budget.foo" , "id" ),
111+ resource .TestCheckResourceAttr (
112+ "datadog_cost_budget.foo" , "entries.0.amount" , "2000" ),
113+ ),
114+ },
115+ },
116+ })
117+ }
118+
80119func testAccCheckDatadogCostBudgetDestroy (provider * fwprovider.FrameworkProvider ) resource.TestCheckFunc {
81120 return func (s * terraform.State ) error {
82121
@@ -264,3 +303,61 @@ resource "datadog_cost_budget" "foo" {
264303 }
265304}` , uniq )
266305}
306+
307+ func testAccCheckDatadogCostBudgetUpdated (uniq string ) string {
308+ return fmt .Sprintf (`
309+ resource "datadog_cost_budget" "foo" {
310+ name = "%s"
311+ metrics_query = "sum:aws.cost.amortized{*}"
312+ start_month = 202401
313+ end_month = 202412
314+ entries {
315+ amount = 2000
316+ month = 202401
317+ }
318+ entries {
319+ amount = 2000
320+ month = 202402
321+ }
322+ entries {
323+ amount = 2000
324+ month = 202403
325+ }
326+ entries {
327+ amount = 2000
328+ month = 202404
329+ }
330+ entries {
331+ amount = 2000
332+ month = 202405
333+ }
334+ entries {
335+ amount = 2000
336+ month = 202406
337+ }
338+ entries {
339+ amount = 2000
340+ month = 202407
341+ }
342+ entries {
343+ amount = 2000
344+ month = 202408
345+ }
346+ entries {
347+ amount = 2000
348+ month = 202409
349+ }
350+ entries {
351+ amount = 2000
352+ month = 202410
353+ }
354+ entries {
355+ amount = 2000
356+ month = 202411
357+ }
358+ entries {
359+ amount = 2000
360+ month = 202412
361+ }
362+ }` , uniq )
363+ }
0 commit comments