diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c2b5e6b..c0ff5fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ FEATURES: * **New Resource:** sumologic_cse_tag_schema (GH-575) * **New Resource:** sumologic_cse_context_action (GH-573) +ENHANCEMENTS: +* resource/sumologic_cse_inventory_entity_group_configuration: Add new fields to support enhanced functionality. (GH-495) + +DEPRECATIONS: +* resource/sumologic_cse_inventory_entity_group_configuration: Deprecated `groups` in favor of `inventory_key`, `inventory_value`. (GH-495) + ## 2.26.0 (September 7, 2023) FEATURES: * **New Resource:** sumologic_muting_schedule (GH-569) diff --git a/sumologic/resource_sumologic_cse_inventory_entity_group_configuration.go b/sumologic/resource_sumologic_cse_inventory_entity_group_configuration.go index 04cb17c0..557d31cb 100644 --- a/sumologic/resource_sumologic_cse_inventory_entity_group_configuration.go +++ b/sumologic/resource_sumologic_cse_inventory_entity_group_configuration.go @@ -18,19 +18,19 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource { Schema: map[string]*schema.Schema{ "criticality": { - Type: schema.TypeString, - Optional: true, - Default: "", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, }, "description": { Type: schema.TypeString, Optional: true, - Default: "", }, "group": { - Type: schema.TypeString, - Optional: true, - Default: "", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + Deprecated: "The field `group` is deprecated and will be removed in a future release of the provider -- please make usage of `inventory_key`, `inventory_value` instead.", }, "inventory_type": { Type: schema.TypeString, @@ -41,9 +41,30 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource { Type: schema.TypeString, Required: true, }, + "inventory_key": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "inventory_value": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "tag_schema": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "dynamic_tags": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, }, "suppressed": { Type: schema.TypeBool, @@ -54,7 +75,8 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource { Type: schema.TypeList, Optional: true, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, }, }, }, @@ -83,6 +105,10 @@ func resourceSumologicCSEInventoryEntityGroupConfigurationRead(d *schema.Resourc d.Set("group", CSEInventoryEntityGroupConfigurationGet.Group) d.Set("inventory_type", CSEInventoryEntityGroupConfigurationGet.InventoryType) d.Set("inventory_source", CSEInventoryEntityGroupConfigurationGet.InventorySource) + d.Set("inventory_key", CSEInventoryEntityGroupConfigurationGet.InventoryKey) + d.Set("inventory_value", CSEInventoryEntityGroupConfigurationGet.InventoryValue) + d.Set("tag_schema", CSEInventoryEntityGroupConfigurationGet.TagSchema) + d.Set("dynamic_tags", CSEInventoryEntityGroupConfigurationGet.DynamicTags) d.Set("name", CSEInventoryEntityGroupConfigurationGet.Name) d.Set("suppressed", CSEInventoryEntityGroupConfigurationGet.Suppressed) d.Set("tags", CSEInventoryEntityGroupConfigurationGet.Tags) @@ -107,6 +133,10 @@ func resourceSumologicCSEInventoryEntityGroupConfigurationCreate(d *schema.Resou Group: d.Get("group").(string), InventoryType: d.Get("inventory_type").(string), InventorySource: d.Get("inventory_source").(string), + InventoryKey: d.Get("inventory_key").(string), + InventoryValue: d.Get("inventory_value").(string), + TagSchema: d.Get("tag_schema").(string), + DynamicTags: d.Get("dynamic_tags").(bool), Name: d.Get("name").(string), Suppressed: d.Get("suppressed").(bool), Tags: resourceToStringArray(d.Get("tags").([]interface{})), @@ -148,6 +178,10 @@ func resourceToCSEInventoryEntityGroupConfiguration(d *schema.ResourceData) (CSE Group: d.Get("group").(string), InventoryType: d.Get("inventory_type").(string), InventorySource: d.Get("inventory_source").(string), + InventoryKey: d.Get("inventory_key").(string), + InventoryValue: d.Get("inventory_value").(string), + TagSchema: d.Get("tag_schema").(string), + DynamicTags: d.Get("dynamic_tags").(bool), Name: d.Get("name").(string), Suppressed: d.Get("suppressed").(bool), Tags: resourceToStringArray(d.Get("tags").([]interface{})), diff --git a/sumologic/resource_sumologic_cse_inventory_entity_group_configuration_test.go b/sumologic/resource_sumologic_cse_inventory_entity_group_configuration_test.go index e05ed9eb..d85dc1b1 100644 --- a/sumologic/resource_sumologic_cse_inventory_entity_group_configuration_test.go +++ b/sumologic/resource_sumologic_cse_inventory_entity_group_configuration_test.go @@ -14,13 +14,18 @@ func TestAccSumologicCSEInventoryEntityGroupConfiguration_createAndUpdate(t *tes var InventoryEntityGroupConfiguration CSEEntityGroupConfiguration criticality := "HIGH" description := "Test description" - group := "goo" + inventoryKey := "groups" + inventoryValue := "red" inventoryType := "computer" inventorySource := "Active Directory" name := "Entity Group Configuration Tf test" suppressed := false tag := "foo" nameUpdated := "Updated Entity Group Configuration" + suppressedUpdated := true + tagUpdated := "goo" + inventoryKeyUpdated := "normalizedHostname" + inventoryValueUpdated := "blue" resourceName := "sumologic_cse_inventory_entity_group_configuration.inventory_entity_group_configuration" resource.Test(t, resource.TestCase{ @@ -29,22 +34,22 @@ func TestAccSumologicCSEInventoryEntityGroupConfiguration_createAndUpdate(t *tes CheckDestroy: testAccCSEInventoryEntityGroupConfigurationDestroy, Steps: []resource.TestStep{ { - Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description, group, - inventoryType, inventorySource, name, suppressed, tag), + Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description, + inventoryType, inventorySource, inventoryKey, inventoryValue, name, suppressed, tag), Check: resource.ComposeTestCheckFunc( testCheckCSEInventoryEntityGroupConfigurationExists(resourceName, &InventoryEntityGroupConfiguration), testCheckInventoryEntityGroupConfigurationValues(&InventoryEntityGroupConfiguration, criticality, - description, group, inventoryType, inventorySource, name, suppressed, tag), + description, inventoryType, inventorySource, inventoryKey, inventoryValue, name, suppressed, tag), resource.TestCheckResourceAttrSet(resourceName, "id"), ), }, { - Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description, group, - inventoryType, inventorySource, nameUpdated, suppressed, tag), + Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description, + inventoryType, inventorySource, inventoryKeyUpdated, inventoryValueUpdated, nameUpdated, suppressedUpdated, tagUpdated), Check: resource.ComposeTestCheckFunc( testCheckCSEInventoryEntityGroupConfigurationExists(resourceName, &InventoryEntityGroupConfiguration), testCheckInventoryEntityGroupConfigurationValues(&InventoryEntityGroupConfiguration, criticality, - description, group, inventoryType, inventorySource, nameUpdated, suppressed, tag), + description, inventoryType, inventorySource, inventoryKeyUpdated, inventoryValueUpdated, nameUpdated, suppressedUpdated, tagUpdated), resource.TestCheckResourceAttrSet(resourceName, "id"), ), }, @@ -77,20 +82,21 @@ func testAccCSEInventoryEntityGroupConfigurationDestroy(s *terraform.State) erro } func testCreateCSEInventoryEntityGroupConfigurationConfig( - criticality string, description string, group string, - inventoryType string, inventorySource string, name string, suppressed bool, tag string) string { + criticality string, description string, + inventoryType string, inventorySource string, inventoryKey string, inventoryValue string, name string, suppressed bool, tag string) string { return fmt.Sprintf(` resource "sumologic_cse_inventory_entity_group_configuration" "inventory_entity_group_configuration" { criticality = "%s" description = "%s" - group = "%s" inventory_type = "%s" inventory_source = "%s" + inventory_key = "%s" + inventory_value = "%s" name = "%s" suppressed = %t tags = ["%s"] } -`, criticality, description, group, inventoryType, inventorySource, name, suppressed, tag) +`, criticality, description, inventoryType, inventorySource, inventoryKey, inventoryValue, name, suppressed, tag) } func testCheckCSEInventoryEntityGroupConfigurationExists(n string, InventoryEntityGroupConfiguration *CSEEntityGroupConfiguration) resource.TestCheckFunc { @@ -117,8 +123,8 @@ func testCheckCSEInventoryEntityGroupConfigurationExists(n string, InventoryEnti } func testCheckInventoryEntityGroupConfigurationValues(InventoryEntityGroupConfiguration *CSEEntityGroupConfiguration, - criticality string, description string, group string, - inventoryType string, inventorySource string, name string, suppressed bool, tag string) resource.TestCheckFunc { + criticality string, description string, + inventoryType string, inventorySource string, inventoryKey string, inventoryValue string, name string, suppressed bool, tag string) resource.TestCheckFunc { return func(s *terraform.State) error { if InventoryEntityGroupConfiguration.Criticality != criticality { return fmt.Errorf("bad criticality, expected \"%s\", got %#v", criticality, InventoryEntityGroupConfiguration.Criticality) @@ -126,8 +132,14 @@ func testCheckInventoryEntityGroupConfigurationValues(InventoryEntityGroupConfig if InventoryEntityGroupConfiguration.Description != description { return fmt.Errorf("bad description, expected \"%s\", got %#v", description, InventoryEntityGroupConfiguration.Description) } - if InventoryEntityGroupConfiguration.Group != group { - return fmt.Errorf("bad group, expected \"%s\", got %#v", tag, InventoryEntityGroupConfiguration.Group) + if InventoryEntityGroupConfiguration.InventoryKey != inventoryKey { + return fmt.Errorf("bad inventoryKey, expected \"%s\", got %#v", inventoryKey, InventoryEntityGroupConfiguration.InventoryKey) + } + if InventoryEntityGroupConfiguration.InventoryValue != inventoryValue { + return fmt.Errorf("bad inventoryValue, expected \"%s\", got %#v", inventoryValue, InventoryEntityGroupConfiguration.InventoryValue) + } + if InventoryEntityGroupConfiguration.DynamicTags != false { + return fmt.Errorf("bad dynamicTags, expected false, got %#v", InventoryEntityGroupConfiguration.DynamicTags) } if InventoryEntityGroupConfiguration.InventoryType != inventoryType { return fmt.Errorf("bad inventoryType, expected \"%s\", got %#v", inventoryType, InventoryEntityGroupConfiguration.InventoryType) diff --git a/sumologic/sumologic_cse_entity_group_configuration.go b/sumologic/sumologic_cse_entity_group_configuration.go index 0cef3384..5c161da7 100644 --- a/sumologic/sumologic_cse_entity_group_configuration.go +++ b/sumologic/sumologic_cse_entity_group_configuration.go @@ -123,6 +123,10 @@ type CSEEntityGroupConfiguration struct { Group string `json:"group,omitempty"` InventoryType string `json:"inventoryType,omitempty"` InventorySource string `json:"inventorySource,omitempty"` + InventoryKey string `json:"inventoryKey,omitempty"` + InventoryValue string `json:"inventoryValue,omitempty"` + DynamicTags bool `json:"dynamicTags,omitempty"` + TagSchema string `json:"tagSchema,omitempty"` LastUpdated string `json:"lastUpdated,omitempty,omitempty"` LastUpdatedBy string `json:"lastUpdatedBy,omitempty,omitempty"` Name string `json:"name,omitempty"` diff --git a/website/docs/r/cse_inventory_entity_group_configuration.html.markdown b/website/docs/r/cse_inventory_entity_group_configuration.html.markdown index 55855172..fe1ad78a 100644 --- a/website/docs/r/cse_inventory_entity_group_configuration.html.markdown +++ b/website/docs/r/cse_inventory_entity_group_configuration.html.markdown @@ -10,9 +10,10 @@ description: |- resource "sumologic_cse_inventory_entity_group_configuration" "inventory_entity_group_configuration" { criticality = "HIGH" description = "Inventory entity group description" - group = "admin" - inventory_type = "user" + inventory_type = "username" inventory_source = "Active Directory" + inventory_key = "groups" + inventory_value = "http_servers" name = "Inventory entity group configuration" suppressed = false tags = ["tag"] @@ -25,9 +26,13 @@ The following arguments are supported: - `criticality` - (Optional) The entity group configuration criticality Examples: "HIGH", "CRITICALITY". - `description` - (Optional) The entity group configuration description. -- `group` - (Optional) The entity group configuration inventory group. -- `inventory_type` - (Required) The inventory type Examples: "computer", "user". +- `group` - (Optional)(Deprecated) The entity group configuration inventory group. The field `group` is deprecated and will be removed in a future release of the provider -- please make usage of `inventory_key`, `inventory_value` instead. +- `inventory_type` - (Required) The inventory type Examples: "computer", "username". - `inventory_source` - (Required) The inventory source Examples: "Active Directory", "Okta". +- `inventory_key` - (Required) The inventory key to apply configuration Examples: "groups", "normalizedHostname", "normalizedComputerName". +- `inventory_value` - (Optional) The inventory value to match. +- `dynamic_tags` - (Optional) If dynamic tags are enabled for configuration. +- `tag_schema` - (Optional) The tag schema to be used for dynamic tags. - `name` - (Required) The entity group configuration name. - `suppresed` - (Optional) The entity group configuration suppressed value - `tags` - (Optional) The entity group configuration tags list.