Skip to content

Commit 7611847

Browse files
authored
Merge pull request #495 from SumoLogic/INVS-1146_Entity_Group_Inventory_enhancements
INVS-1146: Inventory Entity Group enhancements
2 parents b632e21 + 378f7b9 commit 7611847

5 files changed

+90
-29
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ FEATURES:
33
* **New Resource:** sumologic_cse_tag_schema (GH-575)
44
* **New Resource:** sumologic_cse_context_action (GH-573)
55

6+
ENHANCEMENTS:
7+
* resource/sumologic_cse_inventory_entity_group_configuration: Add new fields to support enhanced functionality. (GH-495)
8+
9+
DEPRECATIONS:
10+
* resource/sumologic_cse_inventory_entity_group_configuration: Deprecated `groups` in favor of `inventory_key`, `inventory_value`. (GH-495)
11+
612
## 2.26.0 (September 7, 2023)
713
FEATURES:
814
* **New Resource:** sumologic_muting_schedule (GH-569)

sumologic/resource_sumologic_cse_inventory_entity_group_configuration.go

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource {
1818

1919
Schema: map[string]*schema.Schema{
2020
"criticality": {
21-
Type: schema.TypeString,
22-
Optional: true,
23-
Default: "",
21+
Type: schema.TypeString,
22+
Optional: true,
23+
ValidateFunc: validation.StringIsNotEmpty,
2424
},
2525
"description": {
2626
Type: schema.TypeString,
2727
Optional: true,
28-
Default: "",
2928
},
3029
"group": {
31-
Type: schema.TypeString,
32-
Optional: true,
33-
Default: "",
30+
Type: schema.TypeString,
31+
Optional: true,
32+
ValidateFunc: validation.StringIsNotEmpty,
33+
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.",
3434
},
3535
"inventory_type": {
3636
Type: schema.TypeString,
@@ -41,9 +41,30 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource {
4141
Type: schema.TypeString,
4242
Required: true,
4343
},
44+
"inventory_key": {
45+
Type: schema.TypeString,
46+
Optional: true,
47+
ValidateFunc: validation.StringIsNotEmpty,
48+
},
49+
"inventory_value": {
50+
Type: schema.TypeString,
51+
Optional: true,
52+
ValidateFunc: validation.StringIsNotEmpty,
53+
},
54+
"tag_schema": {
55+
Type: schema.TypeString,
56+
Optional: true,
57+
ValidateFunc: validation.StringIsNotEmpty,
58+
},
59+
"dynamic_tags": {
60+
Type: schema.TypeBool,
61+
Optional: true,
62+
Default: false,
63+
},
4464
"name": {
45-
Type: schema.TypeString,
46-
Required: true,
65+
Type: schema.TypeString,
66+
Required: true,
67+
ValidateFunc: validation.StringIsNotEmpty,
4768
},
4869
"suppressed": {
4970
Type: schema.TypeBool,
@@ -54,7 +75,8 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource {
5475
Type: schema.TypeList,
5576
Optional: true,
5677
Elem: &schema.Schema{
57-
Type: schema.TypeString,
78+
Type: schema.TypeString,
79+
ValidateFunc: validation.StringIsNotEmpty,
5880
},
5981
},
6082
},
@@ -83,6 +105,10 @@ func resourceSumologicCSEInventoryEntityGroupConfigurationRead(d *schema.Resourc
83105
d.Set("group", CSEInventoryEntityGroupConfigurationGet.Group)
84106
d.Set("inventory_type", CSEInventoryEntityGroupConfigurationGet.InventoryType)
85107
d.Set("inventory_source", CSEInventoryEntityGroupConfigurationGet.InventorySource)
108+
d.Set("inventory_key", CSEInventoryEntityGroupConfigurationGet.InventoryKey)
109+
d.Set("inventory_value", CSEInventoryEntityGroupConfigurationGet.InventoryValue)
110+
d.Set("tag_schema", CSEInventoryEntityGroupConfigurationGet.TagSchema)
111+
d.Set("dynamic_tags", CSEInventoryEntityGroupConfigurationGet.DynamicTags)
86112
d.Set("name", CSEInventoryEntityGroupConfigurationGet.Name)
87113
d.Set("suppressed", CSEInventoryEntityGroupConfigurationGet.Suppressed)
88114
d.Set("tags", CSEInventoryEntityGroupConfigurationGet.Tags)
@@ -107,6 +133,10 @@ func resourceSumologicCSEInventoryEntityGroupConfigurationCreate(d *schema.Resou
107133
Group: d.Get("group").(string),
108134
InventoryType: d.Get("inventory_type").(string),
109135
InventorySource: d.Get("inventory_source").(string),
136+
InventoryKey: d.Get("inventory_key").(string),
137+
InventoryValue: d.Get("inventory_value").(string),
138+
TagSchema: d.Get("tag_schema").(string),
139+
DynamicTags: d.Get("dynamic_tags").(bool),
110140
Name: d.Get("name").(string),
111141
Suppressed: d.Get("suppressed").(bool),
112142
Tags: resourceToStringArray(d.Get("tags").([]interface{})),
@@ -148,6 +178,10 @@ func resourceToCSEInventoryEntityGroupConfiguration(d *schema.ResourceData) (CSE
148178
Group: d.Get("group").(string),
149179
InventoryType: d.Get("inventory_type").(string),
150180
InventorySource: d.Get("inventory_source").(string),
181+
InventoryKey: d.Get("inventory_key").(string),
182+
InventoryValue: d.Get("inventory_value").(string),
183+
TagSchema: d.Get("tag_schema").(string),
184+
DynamicTags: d.Get("dynamic_tags").(bool),
151185
Name: d.Get("name").(string),
152186
Suppressed: d.Get("suppressed").(bool),
153187
Tags: resourceToStringArray(d.Get("tags").([]interface{})),

sumologic/resource_sumologic_cse_inventory_entity_group_configuration_test.go

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ func TestAccSumologicCSEInventoryEntityGroupConfiguration_createAndUpdate(t *tes
1414
var InventoryEntityGroupConfiguration CSEEntityGroupConfiguration
1515
criticality := "HIGH"
1616
description := "Test description"
17-
group := "goo"
17+
inventoryKey := "groups"
18+
inventoryValue := "red"
1819
inventoryType := "computer"
1920
inventorySource := "Active Directory"
2021
name := "Entity Group Configuration Tf test"
2122
suppressed := false
2223
tag := "foo"
2324
nameUpdated := "Updated Entity Group Configuration"
25+
suppressedUpdated := true
26+
tagUpdated := "goo"
27+
inventoryKeyUpdated := "normalizedHostname"
28+
inventoryValueUpdated := "blue"
2429

2530
resourceName := "sumologic_cse_inventory_entity_group_configuration.inventory_entity_group_configuration"
2631
resource.Test(t, resource.TestCase{
@@ -29,22 +34,22 @@ func TestAccSumologicCSEInventoryEntityGroupConfiguration_createAndUpdate(t *tes
2934
CheckDestroy: testAccCSEInventoryEntityGroupConfigurationDestroy,
3035
Steps: []resource.TestStep{
3136
{
32-
Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description, group,
33-
inventoryType, inventorySource, name, suppressed, tag),
37+
Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description,
38+
inventoryType, inventorySource, inventoryKey, inventoryValue, name, suppressed, tag),
3439
Check: resource.ComposeTestCheckFunc(
3540
testCheckCSEInventoryEntityGroupConfigurationExists(resourceName, &InventoryEntityGroupConfiguration),
3641
testCheckInventoryEntityGroupConfigurationValues(&InventoryEntityGroupConfiguration, criticality,
37-
description, group, inventoryType, inventorySource, name, suppressed, tag),
42+
description, inventoryType, inventorySource, inventoryKey, inventoryValue, name, suppressed, tag),
3843
resource.TestCheckResourceAttrSet(resourceName, "id"),
3944
),
4045
},
4146
{
42-
Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description, group,
43-
inventoryType, inventorySource, nameUpdated, suppressed, tag),
47+
Config: testCreateCSEInventoryEntityGroupConfigurationConfig(criticality, description,
48+
inventoryType, inventorySource, inventoryKeyUpdated, inventoryValueUpdated, nameUpdated, suppressedUpdated, tagUpdated),
4449
Check: resource.ComposeTestCheckFunc(
4550
testCheckCSEInventoryEntityGroupConfigurationExists(resourceName, &InventoryEntityGroupConfiguration),
4651
testCheckInventoryEntityGroupConfigurationValues(&InventoryEntityGroupConfiguration, criticality,
47-
description, group, inventoryType, inventorySource, nameUpdated, suppressed, tag),
52+
description, inventoryType, inventorySource, inventoryKeyUpdated, inventoryValueUpdated, nameUpdated, suppressedUpdated, tagUpdated),
4853
resource.TestCheckResourceAttrSet(resourceName, "id"),
4954
),
5055
},
@@ -77,20 +82,21 @@ func testAccCSEInventoryEntityGroupConfigurationDestroy(s *terraform.State) erro
7782
}
7883

7984
func testCreateCSEInventoryEntityGroupConfigurationConfig(
80-
criticality string, description string, group string,
81-
inventoryType string, inventorySource string, name string, suppressed bool, tag string) string {
85+
criticality string, description string,
86+
inventoryType string, inventorySource string, inventoryKey string, inventoryValue string, name string, suppressed bool, tag string) string {
8287
return fmt.Sprintf(`
8388
resource "sumologic_cse_inventory_entity_group_configuration" "inventory_entity_group_configuration" {
8489
criticality = "%s"
8590
description = "%s"
86-
group = "%s"
8791
inventory_type = "%s"
8892
inventory_source = "%s"
93+
inventory_key = "%s"
94+
inventory_value = "%s"
8995
name = "%s"
9096
suppressed = %t
9197
tags = ["%s"]
9298
}
93-
`, criticality, description, group, inventoryType, inventorySource, name, suppressed, tag)
99+
`, criticality, description, inventoryType, inventorySource, inventoryKey, inventoryValue, name, suppressed, tag)
94100
}
95101

96102
func testCheckCSEInventoryEntityGroupConfigurationExists(n string, InventoryEntityGroupConfiguration *CSEEntityGroupConfiguration) resource.TestCheckFunc {
@@ -117,17 +123,23 @@ func testCheckCSEInventoryEntityGroupConfigurationExists(n string, InventoryEnti
117123
}
118124

119125
func testCheckInventoryEntityGroupConfigurationValues(InventoryEntityGroupConfiguration *CSEEntityGroupConfiguration,
120-
criticality string, description string, group string,
121-
inventoryType string, inventorySource string, name string, suppressed bool, tag string) resource.TestCheckFunc {
126+
criticality string, description string,
127+
inventoryType string, inventorySource string, inventoryKey string, inventoryValue string, name string, suppressed bool, tag string) resource.TestCheckFunc {
122128
return func(s *terraform.State) error {
123129
if InventoryEntityGroupConfiguration.Criticality != criticality {
124130
return fmt.Errorf("bad criticality, expected \"%s\", got %#v", criticality, InventoryEntityGroupConfiguration.Criticality)
125131
}
126132
if InventoryEntityGroupConfiguration.Description != description {
127133
return fmt.Errorf("bad description, expected \"%s\", got %#v", description, InventoryEntityGroupConfiguration.Description)
128134
}
129-
if InventoryEntityGroupConfiguration.Group != group {
130-
return fmt.Errorf("bad group, expected \"%s\", got %#v", tag, InventoryEntityGroupConfiguration.Group)
135+
if InventoryEntityGroupConfiguration.InventoryKey != inventoryKey {
136+
return fmt.Errorf("bad inventoryKey, expected \"%s\", got %#v", inventoryKey, InventoryEntityGroupConfiguration.InventoryKey)
137+
}
138+
if InventoryEntityGroupConfiguration.InventoryValue != inventoryValue {
139+
return fmt.Errorf("bad inventoryValue, expected \"%s\", got %#v", inventoryValue, InventoryEntityGroupConfiguration.InventoryValue)
140+
}
141+
if InventoryEntityGroupConfiguration.DynamicTags != false {
142+
return fmt.Errorf("bad dynamicTags, expected false, got %#v", InventoryEntityGroupConfiguration.DynamicTags)
131143
}
132144
if InventoryEntityGroupConfiguration.InventoryType != inventoryType {
133145
return fmt.Errorf("bad inventoryType, expected \"%s\", got %#v", inventoryType, InventoryEntityGroupConfiguration.InventoryType)

sumologic/sumologic_cse_entity_group_configuration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ type CSEEntityGroupConfiguration struct {
123123
Group string `json:"group,omitempty"`
124124
InventoryType string `json:"inventoryType,omitempty"`
125125
InventorySource string `json:"inventorySource,omitempty"`
126+
InventoryKey string `json:"inventoryKey,omitempty"`
127+
InventoryValue string `json:"inventoryValue,omitempty"`
128+
DynamicTags bool `json:"dynamicTags,omitempty"`
129+
TagSchema string `json:"tagSchema,omitempty"`
126130
LastUpdated string `json:"lastUpdated,omitempty,omitempty"`
127131
LastUpdatedBy string `json:"lastUpdatedBy,omitempty,omitempty"`
128132
Name string `json:"name,omitempty"`

website/docs/r/cse_inventory_entity_group_configuration.html.markdown

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ description: |-
1010
resource "sumologic_cse_inventory_entity_group_configuration" "inventory_entity_group_configuration" {
1111
criticality = "HIGH"
1212
description = "Inventory entity group description"
13-
group = "admin"
14-
inventory_type = "user"
13+
inventory_type = "username"
1514
inventory_source = "Active Directory"
15+
inventory_key = "groups"
16+
inventory_value = "http_servers"
1617
name = "Inventory entity group configuration"
1718
suppressed = false
1819
tags = ["tag"]
@@ -25,9 +26,13 @@ The following arguments are supported:
2526

2627
- `criticality` - (Optional) The entity group configuration criticality Examples: "HIGH", "CRITICALITY".
2728
- `description` - (Optional) The entity group configuration description.
28-
- `group` - (Optional) The entity group configuration inventory group.
29-
- `inventory_type` - (Required) The inventory type Examples: "computer", "user".
29+
- `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.
30+
- `inventory_type` - (Required) The inventory type Examples: "computer", "username".
3031
- `inventory_source` - (Required) The inventory source Examples: "Active Directory", "Okta".
32+
- `inventory_key` - (Required) The inventory key to apply configuration Examples: "groups", "normalizedHostname", "normalizedComputerName".
33+
- `inventory_value` - (Optional) The inventory value to match.
34+
- `dynamic_tags` - (Optional) If dynamic tags are enabled for configuration.
35+
- `tag_schema` - (Optional) The tag schema to be used for dynamic tags.
3136
- `name` - (Required) The entity group configuration name.
3237
- `suppresed` - (Optional) The entity group configuration suppressed value
3338
- `tags` - (Optional) The entity group configuration tags list.

0 commit comments

Comments
 (0)