Skip to content

Commit

Permalink
BE-468: Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-sumologic committed Jan 23, 2025
1 parent ed51611 commit 2896a79
Showing 3 changed files with 112 additions and 47 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## X.Y.Z (Unreleased)
* Add new change notes here
* **New Resource:** sumologic_scan_budget

## 3.0.1 (January 17, 2025)
**ENHANCEMENTS:**
99 changes: 53 additions & 46 deletions sumologic/resource_sumologic_scan_budget_test.go
Original file line number Diff line number Diff line change
@@ -31,8 +31,7 @@ func TestAccSumologicScanBudget_basic(t *testing.T) {
testWindow := "Query"
testApplicableOn := "PerEntity"
testGroupBy := "User"
testAction := "StopScan"
testScope := "j"
testAction := "StopForeGroundScan"
testStatus := "active"

resource.Test(t, resource.TestCase{
@@ -41,7 +40,7 @@ func TestAccSumologicScanBudget_basic(t *testing.T) {
CheckDestroy: testAccCheckScanBudgetDestroy(scanBudget),
Steps: []resource.TestStep{
{
Config: testAccCheckSumologicScanBudgetConfigImported(testName, testCapacity, testUnit, testBudgetType, testWindow, testApplicableOn, testGroupBy, testAction, testScope, testStatus),
Config: testAccCheckSumologicScanBudgetConfigImported(testName, testCapacity, testUnit, testBudgetType, testWindow, testApplicableOn, testGroupBy, testAction, testStatus),
},
{
ResourceName: "sumologic_scan_budget.foo",
@@ -61,8 +60,7 @@ func TestAccSumologicScanBudget_create(t *testing.T) {
testWindow := "Query"
testApplicableOn := "PerEntity"
testGroupBy := "User"
testAction := "StopScan"
testScope := "j"
testAction := "StopForeGroundScan"
testStatus := "active"

resource.Test(t, resource.TestCase{
@@ -71,19 +69,18 @@ func TestAccSumologicScanBudget_create(t *testing.T) {
CheckDestroy: testAccCheckScanBudgetDestroy(scanBudget),
Steps: []resource.TestStep{
{
Config: testAccSumologicScanBudget(testName, testCapacity, testUnit, testBudgetType, testWindow, testApplicableOn, testGroupBy, testAction, testScope, testStatus),
Config: testAccSumologicScanBudget(testName, testCapacity, testUnit, testBudgetType, testWindow, testApplicableOn, testGroupBy, testAction, testStatus),
Check: resource.ComposeTestCheckFunc(
testAccCheckScanBudgetExists("sumologic_scan_budget.test", &scanBudget, t),
testAccCheckScanBudgetAttributes("sumologic_scan_budget.test"),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "name", testName),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "capacity", strconv.Itoa(testCapacity)),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "unit", testUnit),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "budgetType", testBudgetType),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "budget_type", testBudgetType),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "window", testWindow),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "applicableOn", testApplicableOn),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "groupBy", testGroupBy),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "applicable_on", testApplicableOn),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "group_by", testGroupBy),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "action", testAction),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "scope", testScope),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "status", testStatus),
),
},
@@ -101,8 +98,7 @@ func TestAccSumologicScanBudget_update(t *testing.T) {
testWindow := "Query"
testApplicableOn := "PerEntity"
testGroupBy := "User"
testAction := "StopScan"
testScope := "j"
testAction := "StopForeGroundScan"
testStatus := "active"

testUpdatedName := "Test Budget"
@@ -112,8 +108,7 @@ func TestAccSumologicScanBudget_update(t *testing.T) {
testUpdatedWindow := "Daily"
testUpdatedApplicableOn := "PerEntity"
testUpdatedGroupBy := "User"
testUpdatedAction := "StopScan"
testUpdatedScope := "j"
testUpdatedAction := "Warn"
testUpdatedStatus := "active"

resource.Test(t, resource.TestCase{
@@ -122,34 +117,32 @@ func TestAccSumologicScanBudget_update(t *testing.T) {
CheckDestroy: testAccCheckScanBudgetDestroy(scanBudget),
Steps: []resource.TestStep{
{
Config: testAccSumologicScanBudget(testName, testCapacity, testUnit, testBudgetType, testWindow, testApplicableOn, testGroupBy, testAction, testScope, testStatus),
Config: testAccSumologicScanBudget(testName, testCapacity, testUnit, testBudgetType, testWindow, testApplicableOn, testGroupBy, testAction, testStatus),
Check: resource.ComposeTestCheckFunc(
testAccCheckScanBudgetExists("sumologic_scan_budget.test", &scanBudget, t),
testAccCheckScanBudgetAttributes("sumologic_scan_budget.test"),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "name", testName),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "capacity", strconv.Itoa(testCapacity)),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "unit", testUnit),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "budgetType", testBudgetType),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "budget_type", testBudgetType),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "window", testWindow),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "applicableOn", testApplicableOn),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "groupBy", testGroupBy),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "applicable_on", testApplicableOn),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "group_by", testGroupBy),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "action", testAction),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "scope", testScope),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "status", testStatus),
),
},
{
Config: testAccSumologicScanBudgetUpdate(testUpdatedName, testUpdatedCapacity, testUpdatedUnit, testUpdatedBudgetType, testUpdatedWindow, testUpdatedApplicableOn, testUpdatedGroupBy, testUpdatedAction, testUpdatedScope, testUpdatedStatus),
Config: testAccSumologicScanBudgetUpdate(testUpdatedName, testUpdatedCapacity, testUpdatedUnit, testUpdatedBudgetType, testUpdatedWindow, testUpdatedApplicableOn, testUpdatedGroupBy, testUpdatedAction, testUpdatedStatus),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "name", testUpdatedName),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "capacity", strconv.Itoa(testUpdatedCapacity)),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "unit", testUpdatedUnit),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "budgetType", testUpdatedBudgetType),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "budget_type", testUpdatedBudgetType),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "window", testUpdatedWindow),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "applicableOn", testUpdatedApplicableOn),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "groupBy", testUpdatedGroupBy),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "applicable_on", testUpdatedApplicableOn),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "group_by", testUpdatedGroupBy),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "action", testUpdatedAction),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "scope", testUpdatedScope),
resource.TestCheckResourceAttr("sumologic_scan_budget.test", "status", testUpdatedStatus),
),
},
@@ -197,55 +190,70 @@ func testAccCheckScanBudgetExists(name string, scanBudget *ScanBudget, t *testin
return nil
}
}
func testAccCheckSumologicScanBudgetConfigImported(name string, capacity int, unit string, budgetType string, window string, applicableOn string, groupBy string, action string, scope string, status string) string {
func testAccCheckSumologicScanBudgetConfigImported(name string, capacity int, unit string, budgetType string, window string, applicableOn string, groupBy string, action string, status string) string {
return fmt.Sprintf(`
resource "sumologic_scan_budget" "foo" {
name = "%s"
capacity = %d
unit = "%s"
budgetType = "%s"
budget_type = "%s"
window = "%s"
applicableOn = "%s"
groupBy = "%s"
applicable_on = "%s"
group_by = "%s"
action = "%s"
scope = "%s"
scope {
included_users = ["000000000000011C"]
excluded_users = []
included_roles = []
excluded_roles = ["0000000000000196"]
}
status = "%s"
}
`, name, capacity, unit, budgetType, window, applicableOn, groupBy, action, scope, status)
`, name, capacity, unit, budgetType, window, applicableOn, groupBy, action, status)
}

func testAccSumologicScanBudget(name string, capacity int, unit string, budgetType string, window string, applicableOn string, groupBy string, action string, scope string, status string) string {
func testAccSumologicScanBudget(name string, capacity int, unit string, budgetType string, window string, applicableOn string, groupBy string, action string, status string) string {
return fmt.Sprintf(`
resource "sumologic_scan_budget" "test" {
name = "%s"
capacity = %d
unit = "%s"
budgetType = "%s"
budget_type = "%s"
window = "%s"
applicableOn = "%s"
groupBy = "%s"
applicable_on = "%s"
group_by = "%s"
action = "%s"
scope = "%s"
scope {
included_users = ["000000000000011C"]
excluded_users = []
included_roles = []
excluded_roles = ["0000000000000196"]
}
status = "%s"
}
`, name, capacity, unit, budgetType, window, applicableOn, groupBy, action, scope, status)
`, name, capacity, unit, budgetType, window, applicableOn, groupBy, action, status)
}

func testAccSumologicScanBudgetUpdate(name string, capacity int, unit string, budgetType string, window string, applicableOn string, groupBy string, action string, scope string, status string) string {
func testAccSumologicScanBudgetUpdate(name string, capacity int, unit string, budgetType string, window string, applicableOn string, groupBy string, action string, status string) string {
return fmt.Sprintf(`
resource "sumologic_scan_budget" "test" {
name = "%s"
capacity = %d
unit = "%s"
budgetType = "%s"
budget_type = "%s"
window = "%s"
applicableOn = "%s"
groupBy = "%s"
applicable_on = "%s"
group_by = "%s"
action = "%s"
scope = "%s"
scope {
included_users = ["000000000000011C"]
excluded_users = []
included_roles = []
excluded_roles = ["0000000000000196"]
}
status = "%s"
}
`, name, capacity, unit, budgetType, window, applicableOn, groupBy, action, scope, status)
`, name, capacity, unit, budgetType, window, applicableOn, groupBy, action, status)
}

func testAccCheckScanBudgetAttributes(name string) resource.TestCheckFunc {
@@ -254,12 +262,11 @@ func testAccCheckScanBudgetAttributes(name string) resource.TestCheckFunc {
resource.TestCheckResourceAttrSet(name, "name"),
resource.TestCheckResourceAttrSet(name, "capacity"),
resource.TestCheckResourceAttrSet(name, "unit"),
resource.TestCheckResourceAttrSet(name, "budgetType"),
resource.TestCheckResourceAttrSet(name, "budget_type"),
resource.TestCheckResourceAttrSet(name, "window"),
resource.TestCheckResourceAttrSet(name, "applicableOn"),
resource.TestCheckResourceAttrSet(name, "groupBy"),
resource.TestCheckResourceAttrSet(name, "applicable_on"),
resource.TestCheckResourceAttrSet(name, "group_by"),
resource.TestCheckResourceAttrSet(name, "action"),
resource.TestCheckResourceAttrSet(name, "scope"),
resource.TestCheckResourceAttrSet(name, "status"),
)
return f(s)
58 changes: 58 additions & 0 deletions website/docs/r/scan_budget.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
layout: "sumologic"
page_title: "SumoLogic: sumologic_scan_budget"
description: |-
Provides a Sumologic Scan Budget
---

# sumologic_scan_budget
Provides a [Sumologic Scan Budget][1].

## Example Usage
```hcl
resource "sumologic_scan_budget" "budget" {
name = "TestBudget"
capacity = 10
unit = "GB"
budget_type = "ScanBudget"
window = "Query"
applicable_on = "PerEntity"
group_by = "User"
action = "StopScan"
status = "active"
scope {
included_users = ["000000000000011C"]
excluded_users = []
included_roles = []
excluded_roles = ["0000000000000196"]
}
}
```

## Argument Reference

The following arguments are supported:

* `name` - (Required) Display name of the scan budget. This must be unique across all the scan budgets.
* `capacity` - (Required) Capacity of the scan budget. Only whole numbers are supported.
* `unit` - (Required) Unit of the capacity. Supported values are: `MB`, `GB` and `TB`.
* `budget_type` - (Required) Type of the budget. Supported values are: `ScanBudget`.
* `window` - (Required) Window of the budget. Supported values are: `Query`, `Daily`, `Weekly` and `Monthly`.
* `applicable_on` - (Required) Grouping of the budget. Supported values are: `PerEntity` and `Sum`.
* `group_by` - (Required) Grouping Entity of the budget. Supported values are: `User`.
* `action` - (Required) Action to be taken if the budget is breached. Supported values are: `StopForeGroundScan` and `Warn`.
* `scope` - (Required) Scope of the budget.
* `status` - (Required) Signifies the state of the budget. Supported values are: `active` and `inactive`.

The following attributes are exported:

* `id` - The internal ID of the budget.

## Import
Scan budgets can be imported using the budget ID, e.g.:

```hcl
terraform import sumologic_scan_budget.budget 00000000000123AB
```

[1]: https://help.sumologic.com/docs/manage/manage-subscription/usage-management/

0 comments on commit 2896a79

Please sign in to comment.