Skip to content

Commit

Permalink
Merge branch 'master' into pgupta-terraform-monitor-tags-support
Browse files Browse the repository at this point in the history
  • Loading branch information
pgupta-sumo authored Aug 21, 2023
2 parents 4107541 + 2d22ca3 commit 29f1339
Show file tree
Hide file tree
Showing 18 changed files with 780 additions and 40 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
## 2.24.1 (Unreleased)
## 2.25.1 (Unreleased)

## 2.25.0 (August 8, 2023)
FEATURES:
* **New Resource:** sumologic_metrics_search (GH-528)
* resource/sumologic_monitor: Added support for associating tags with a Monitor.
* **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)
* Fixes `sumologic_s3_source` to allow setting `use_versioned_api` parameter to `false`. (GH-555)

DEPRECATIONS:
* resource_sumologic_ingest_budget : Deprecated in favour of `resource_sumologic_ingest_budget_v2`.

## 2.24.0 (June 22, 2023)
FEATURES:
Expand Down
1 change: 1 addition & 0 deletions sumologic/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func Provider() terraform.ResourceProvider {
"sumologic_local_file_source": resourceSumologicLocalFileSource(),
"sumologic_log_search": resourceSumologicLogSearch(),
"sumologic_metrics_search": resourceSumologicMetricsSearch(),
"sumologic_rum_source": resourceSumologicRumSource(),
},
DataSourcesMap: map[string]*schema.Resource{
"sumologic_cse_log_mapping_vendor_product": dataSourceCSELogMappingVendorAndProduct(),
Expand Down
11 changes: 10 additions & 1 deletion sumologic/resource_sumologic_generic_polling_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
"use_versioned_api": {
Type: schema.TypeBool,
Optional: true,
Default: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
contentType := d.Get("content_type").(string)
if contentType != "AwsS3Bucket" {
return true
}
return false
},
},
"path_expression": {
Type: schema.TypeString,
Expand Down Expand Up @@ -578,7 +586,8 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
pathSettings.BucketName = path["bucket_name"].(string)
pathSettings.PathExpression = path["path_expression"].(string)
if path["use_versioned_api"] != nil {
pathSettings.UseVersionedApi = path["use_versioned_api"].(bool)
val := path["use_versioned_api"].(bool)
pathSettings.UseVersionedApi = &val
}
pathSettings.SnsTopicOrSubscriptionArn = getPollingSnsTopicOrSubscriptionArn(d)
case "CloudWatchPath", "AwsInventoryPath":
Expand Down
12 changes: 7 additions & 5 deletions sumologic/resource_sumologic_ingest_budget.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package sumologic

import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"log"
)

func resourceSumologicIngestBudget() *schema.Resource {
return &schema.Resource{
Create: resourceSumologicIngestBudgetCreate,
Read: resourceSumologicIngestBudgetRead,
Delete: resourceSumologicIngestBudgetDelete,
Update: resourceSumologicIngestBudgetUpdate,
DeprecationMessage: "Use resource_sumologic_ingest_budget_v2 instead.",
Create: resourceSumologicIngestBudgetCreate,
Read: resourceSumologicIngestBudgetRead,
Delete: resourceSumologicIngestBudgetDelete,
Update: resourceSumologicIngestBudgetUpdate,
Importer: &schema.ResourceImporter{
State: resourceSumologicIngestBudgetImport,
},
Expand Down
9 changes: 9 additions & 0 deletions sumologic/resource_sumologic_ingest_budget_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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),
Expand Down
31 changes: 21 additions & 10 deletions sumologic/resource_sumologic_ingest_budget_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ func TestAccSumologicIngestBudgetV2_basic(t *testing.T) {
testDescription := "description-7hUwr"
testAction := "stopCollecting"
testCapacityBytes := 1000
testBudgetType := "dailyVolume"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
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",
Expand All @@ -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"),
Expand All @@ -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),
),
},
},
Expand All @@ -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"
Expand All @@ -101,14 +105,15 @@ func TestAccSumologicIngestBudgetV2_update(t *testing.T) {
testUpdatedDescription := "description-pY8kDUpdate"
testUpdatedAction := "keepCollecting"
testUpdatedCapacityBytes := 1001
testUpdatedBudgetType := "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"),
Expand All @@ -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),
Expand All @@ -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),
),
},
},
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 29f1339

Please sign in to comment.