diff --git a/CHANGELOG.md b/CHANGELOG.md index a1621315..456cccc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ FEATURES: * **New Resource:** sumologic_metrics_search (GH-528) * **New Resource:** sumologic_rum_source (GH-547) +* Add `budgetType` support for sumologic_ingest_budget_v2 (GH-549) BUG FIXES: * Enforce non-empty string validation of `default_normalized_domain` and `domain_mappings` in cse_entity_normalization resource. (GH-540) diff --git a/sumologic/resource_sumologic_ingest_budget_v2.go b/sumologic/resource_sumologic_ingest_budget_v2.go index b89217b4..3ca0879a 100644 --- a/sumologic/resource_sumologic_ingest_budget_v2.go +++ b/sumologic/resource_sumologic_ingest_budget_v2.go @@ -71,6 +71,13 @@ func resourceSumologicIngestBudgetV2() *schema.Resource { ForceNew: false, }, + "budget_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: false, + Default: "dailyVolume", + }, + "name": { Type: schema.TypeString, Required: true, @@ -119,6 +126,7 @@ func resourceSumologicIngestBudgetV2Read(d *schema.ResourceData, meta interface{ d.Set("description", ingestBudgetV2.Description) d.Set("action", ingestBudgetV2.Action) d.Set("capacity_bytes", ingestBudgetV2.CapacityBytes) + d.Set("budget_type", ingestBudgetV2.BudgetType) return nil } @@ -150,6 +158,7 @@ func resourceToIngestBudgetV2(d *schema.ResourceData) IngestBudgetV2 { Timezone: d.Get("timezone").(string), ID: d.Id(), Action: d.Get("action").(string), + BudgetType: d.Get("budget_type").(string), Description: d.Get("description").(string), AuditThreshold: d.Get("audit_threshold").(int), CapacityBytes: d.Get("capacity_bytes").(int), diff --git a/sumologic/resource_sumologic_ingest_budget_v2_test.go b/sumologic/resource_sumologic_ingest_budget_v2_test.go index 3aeff3af..48834162 100644 --- a/sumologic/resource_sumologic_ingest_budget_v2_test.go +++ b/sumologic/resource_sumologic_ingest_budget_v2_test.go @@ -31,6 +31,7 @@ func TestAccSumologicIngestBudgetV2_basic(t *testing.T) { testDescription := "description-7hUwr" testAction := "stopCollecting" testCapacityBytes := 1000 + testBudgetType := "dailyVolume" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -38,7 +39,7 @@ func TestAccSumologicIngestBudgetV2_basic(t *testing.T) { CheckDestroy: testAccCheckIngestBudgetV2Destroy(ingestBudgetV2), Steps: []resource.TestStep{ { - Config: testAccCheckSumologicIngestBudgetV2ConfigImported(testName, testScope, testTimezone, testResetTime, testAuditThreshold, testDescription, testAction, testCapacityBytes), + Config: testAccCheckSumologicIngestBudgetV2ConfigImported(testName, testScope, testTimezone, testResetTime, testAuditThreshold, testDescription, testAction, testCapacityBytes, testBudgetType), }, { ResourceName: "sumologic_ingest_budget_v2.foo", @@ -58,13 +59,14 @@ func TestAccSumologicIngestBudgetV2_create(t *testing.T) { testDescription := "description-900AB" testAction := "stopCollecting" testCapacityBytes := 1000 + testBudgetType := "dailyVolume" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckIngestBudgetV2Destroy(ingestBudgetV2), Steps: []resource.TestStep{ { - Config: testAccSumologicIngestBudgetV2(testName, testScope, testTimezone, testResetTime, testAuditThreshold, testDescription, testAction, testCapacityBytes), + Config: testAccSumologicIngestBudgetV2(testName, testScope, testTimezone, testResetTime, testAuditThreshold, testDescription, testAction, testCapacityBytes, testBudgetType), Check: resource.ComposeTestCheckFunc( testAccCheckIngestBudgetV2Exists("sumologic_ingest_budget_v2.test", &ingestBudgetV2, t), testAccCheckIngestBudgetV2Attributes("sumologic_ingest_budget_v2.test"), @@ -76,6 +78,7 @@ func TestAccSumologicIngestBudgetV2_create(t *testing.T) { resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "description", testDescription), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "action", testAction), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "capacity_bytes", strconv.Itoa(testCapacityBytes)), + resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "budget_type", testBudgetType), ), }, }, @@ -92,6 +95,7 @@ func TestAccSumologicIngestBudgetV2_update(t *testing.T) { testDescription := "description-2tAk8" testAction := "stopCollecting" testCapacityBytes := 1000 + testBudgetType := "dailyVolume" testUpdatedName := "Developer BudgetUpdate" testUpdatedScope := "_sourceCategory=*prod*nginx*Update" @@ -101,6 +105,7 @@ func TestAccSumologicIngestBudgetV2_update(t *testing.T) { testUpdatedDescription := "description-pY8kDUpdate" testUpdatedAction := "keepCollecting" testUpdatedCapacityBytes := 1001 + testUpdatedBudgetType := "dailyVolume" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -108,7 +113,7 @@ func TestAccSumologicIngestBudgetV2_update(t *testing.T) { CheckDestroy: testAccCheckIngestBudgetV2Destroy(ingestBudgetV2), Steps: []resource.TestStep{ { - Config: testAccSumologicIngestBudgetV2(testName, testScope, testTimezone, testResetTime, testAuditThreshold, testDescription, testAction, testCapacityBytes), + Config: testAccSumologicIngestBudgetV2(testName, testScope, testTimezone, testResetTime, testAuditThreshold, testDescription, testAction, testCapacityBytes, testBudgetType), Check: resource.ComposeTestCheckFunc( testAccCheckIngestBudgetV2Exists("sumologic_ingest_budget_v2.test", &ingestBudgetV2, t), testAccCheckIngestBudgetV2Attributes("sumologic_ingest_budget_v2.test"), @@ -120,10 +125,11 @@ func TestAccSumologicIngestBudgetV2_update(t *testing.T) { resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "description", testDescription), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "action", testAction), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "capacity_bytes", strconv.Itoa(testCapacityBytes)), + resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "budget_type", testBudgetType), ), }, { - Config: testAccSumologicIngestBudgetV2Update(testUpdatedName, testUpdatedScope, testUpdatedTimezone, testUpdatedResetTime, testUpdatedAuditThreshold, testUpdatedDescription, testUpdatedAction, testUpdatedCapacityBytes), + Config: testAccSumologicIngestBudgetV2Update(testUpdatedName, testUpdatedScope, testUpdatedTimezone, testUpdatedResetTime, testUpdatedAuditThreshold, testUpdatedDescription, testUpdatedAction, testUpdatedCapacityBytes, testUpdatedBudgetType), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "name", testUpdatedName), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "scope", testUpdatedScope), @@ -133,6 +139,7 @@ func TestAccSumologicIngestBudgetV2_update(t *testing.T) { resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "description", testUpdatedDescription), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "action", testUpdatedAction), resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "capacity_bytes", strconv.Itoa(testUpdatedCapacityBytes)), + resource.TestCheckResourceAttr("sumologic_ingest_budget_v2.test", "budget_type", testUpdatedBudgetType), ), }, }, @@ -179,7 +186,7 @@ func testAccCheckIngestBudgetV2Exists(name string, ingestBudgetV2 *IngestBudgetV return nil } } -func testAccCheckSumologicIngestBudgetV2ConfigImported(name string, scope string, timezone string, resetTime string, auditThreshold int, description string, action string, capacityBytes int) string { +func testAccCheckSumologicIngestBudgetV2ConfigImported(name string, scope string, timezone string, resetTime string, auditThreshold int, description string, action string, capacityBytes int, budgetType string) string { return fmt.Sprintf(` resource "sumologic_ingest_budget_v2" "foo" { name = "%s" @@ -190,11 +197,12 @@ resource "sumologic_ingest_budget_v2" "foo" { description = "%s" action = "%s" capacity_bytes = %d + budget_type = "%s" } -`, name, scope, timezone, resetTime, auditThreshold, description, action, capacityBytes) +`, name, scope, timezone, resetTime, auditThreshold, description, action, capacityBytes, budgetType) } -func testAccSumologicIngestBudgetV2(name string, scope string, timezone string, resetTime string, auditThreshold int, description string, action string, capacityBytes int) string { +func testAccSumologicIngestBudgetV2(name string, scope string, timezone string, resetTime string, auditThreshold int, description string, action string, capacityBytes int, budgetType string) string { return fmt.Sprintf(` resource "sumologic_ingest_budget_v2" "test" { name = "%s" @@ -205,11 +213,12 @@ resource "sumologic_ingest_budget_v2" "test" { description = "%s" action = "%s" capacity_bytes = %d + budget_type = "%s" } -`, name, scope, timezone, resetTime, auditThreshold, description, action, capacityBytes) +`, name, scope, timezone, resetTime, auditThreshold, description, action, capacityBytes, budgetType) } -func testAccSumologicIngestBudgetV2Update(name string, scope string, timezone string, resetTime string, auditThreshold int, description string, action string, capacityBytes int) string { +func testAccSumologicIngestBudgetV2Update(name string, scope string, timezone string, resetTime string, auditThreshold int, description string, action string, capacityBytes int, budgetType string) string { return fmt.Sprintf(` resource "sumologic_ingest_budget_v2" "test" { name = "%s" @@ -220,8 +229,9 @@ resource "sumologic_ingest_budget_v2" "test" { description = "%s" action = "%s" capacity_bytes = %d + budget_type = "%s" } -`, name, scope, timezone, resetTime, auditThreshold, description, action, capacityBytes) +`, name, scope, timezone, resetTime, auditThreshold, description, action, capacityBytes, budgetType) } func testAccCheckIngestBudgetV2Attributes(name string) resource.TestCheckFunc { @@ -234,6 +244,7 @@ func testAccCheckIngestBudgetV2Attributes(name string) resource.TestCheckFunc { resource.TestCheckResourceAttrSet(name, "audit_threshold"), resource.TestCheckResourceAttrSet(name, "description"), resource.TestCheckResourceAttrSet(name, "action"), + resource.TestCheckResourceAttrSet(name, "budget_type"), resource.TestCheckResourceAttrSet(name, "capacity_bytes"), ) return f(s) diff --git a/sumologic/sumologic_ingest_budget_v2.go b/sumologic/sumologic_ingest_budget_v2.go index a3347dd1..eac49a78 100644 --- a/sumologic/sumologic_ingest_budget_v2.go +++ b/sumologic/sumologic_ingest_budget_v2.go @@ -96,6 +96,7 @@ type IngestBudgetV2 struct { Action string `json:"action"` ResetTime string `json:"resetTime"` Name string `json:"name"` + BudgetType string `json:"budgetType,omitempty"` ID string `json:"id,omitempty"` Scope string `json:"scope"` Timezone string `json:"timezone"` diff --git a/website/docs/r/ingest_budget_v2.html.markdown b/website/docs/r/ingest_budget_v2.html.markdown index af5dac65..27f7d34c 100644 --- a/website/docs/r/ingest_budget_v2.html.markdown +++ b/website/docs/r/ingest_budget_v2.html.markdown @@ -13,6 +13,7 @@ Provides a [Sumologic Ingest Budget v2][1]. resource "sumologic_ingest_budget_v2" "budget" { name = "testBudget" scope = "_sourceCategory=*prod*nginx*" + budget_type = "dailyVolume" capacity_bytes = 30000000000 description = "For testing purposes" timezone = "Etc/UTC" @@ -28,8 +29,9 @@ The following arguments are supported: * `name` - (Required) Display name of the ingest budget. This must be unique across all of the ingest budgets * `scope` - (Required) A scope is a constraint that will be used to identify the messages on which budget needs to be applied. A scope is consists of key and value separated by =. The field must be enabled in the fields table. - * `capacity_bytes` - (Required) Capacity of the ingest budget, in bytes. + * `capacity_bytes` - (Required) Capacity of the ingest budget, in bytes. It takes a few minutes for Collectors to stop collecting when capacity is reached. We recommend setting a soft limit that is lower than your needed hard limit. The capacity bytes unit varies based on the budgetType field. For `dailyVolume` budgetType the capacity specified is in bytes/day whereas for `minuteVolume` budgetType its bytes/min. * `description` - (Optional) The description of the collector. + * `budget_type` - (Optional) The type of budget. Supported values are: * `dailyVolume` * `minuteVolume`. Default value is `dailyVolume`. * `timezone` - (Optional) The time zone to use for this collector. The value follows the [tzdata][2] naming convention. Defaults to `Etc/UTC` * `action` - (Optional) Action to take when ingest budget's capacity is reached. All actions are audited. Supported values are `stopCollecting` and `keepCollecting`. * `reset_time` - (Optional) Reset time of the ingest budget in HH:MM format. Defaults to `00:00` @@ -40,10 +42,10 @@ The following attributes are exported: * `id` - The internal ID of the ingest budget. ## Import -Ingest budgets can be imported using the name, e.g.: +Ingest budgets can be imported using the budget ID, e.g.: ```hcl -terraform import sumologic_ingest_budget_v2.budget budgetName +terraform import sumologic_ingest_budget_v2.budget 00000000000123AB ``` [1]: https://help.sumologic.com/Beta/Metadata_Ingest_Budgets