Skip to content

Commit eb5c264

Browse files
author
Pedro Montiel
committed
INVS-1146: Inventory Entity Group enhancements - use new fields
1 parent c838185 commit eb5c264

5 files changed

+77
-20
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
## 2.21.1 (Unreleased)
2+
ENHANCEMENTS:
3+
* resource/sumologic_cse_inventory_entity_group_configuration: Add new fields to support enhanced functionality. (GH-495)
4+
5+
DEPRECATIONS:
6+
* resource/sumologic_cse_inventory_entity_group_configuration: Deprecated `groups` in favor of `inventory_key`, `inventory_value`. (GH-495)
7+
28

39
## 2.21.0 (February 27, 2023)
410
FEATURES:

sumologic/resource_sumologic_cse_inventory_entity_group_configuration.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource {
2727
Default: "",
2828
},
2929
"group": {
30-
Type: schema.TypeString,
31-
Optional: true,
32-
Default: "",
30+
Type: schema.TypeString,
31+
Optional: true,
32+
Default: "",
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.",
3334
},
3435
"inventory_type": {
3536
Type: schema.TypeString,
@@ -39,6 +40,23 @@ func resourceSumologicCSEInventoryEntityGroupConfiguration() *schema.Resource {
3940
Type: schema.TypeString,
4041
Required: true,
4142
},
43+
"inventory_key": {
44+
Type: schema.TypeString,
45+
Optional: true,
46+
},
47+
"inventory_value": {
48+
Type: schema.TypeString,
49+
Optional: true,
50+
},
51+
"tag_schema": {
52+
Type: schema.TypeString,
53+
Optional: true,
54+
},
55+
"dynamic_tags": {
56+
Type: schema.TypeBool,
57+
Optional: true,
58+
Default: false,
59+
},
4260
"name": {
4361
Type: schema.TypeString,
4462
Required: true,
@@ -81,6 +99,10 @@ func resourceSumologicCSEInventoryEntityGroupConfigurationRead(d *schema.Resourc
8199
d.Set("group", CSEInventoryEntityGroupConfigurationGet.Group)
82100
d.Set("inventory_type", CSEInventoryEntityGroupConfigurationGet.InventoryType)
83101
d.Set("inventory_source", CSEInventoryEntityGroupConfigurationGet.InventorySource)
102+
d.Set("inventory_key", CSEInventoryEntityGroupConfigurationGet.InventoryKey)
103+
d.Set("inventory_value", CSEInventoryEntityGroupConfigurationGet.InventoryValue)
104+
d.Set("tag_schema", CSEInventoryEntityGroupConfigurationGet.TagSchema)
105+
d.Set("dynamic_tags", CSEInventoryEntityGroupConfigurationGet.DynamicTags)
84106
d.Set("name", CSEInventoryEntityGroupConfigurationGet.Name)
85107
d.Set("suppressed", CSEInventoryEntityGroupConfigurationGet.Suppressed)
86108
d.Set("tags", CSEInventoryEntityGroupConfigurationGet.Tags)
@@ -105,6 +127,10 @@ func resourceSumologicCSEInventoryEntityGroupConfigurationCreate(d *schema.Resou
105127
Group: d.Get("group").(string),
106128
InventoryType: d.Get("inventory_type").(string),
107129
InventorySource: d.Get("inventory_source").(string),
130+
InventoryKey: d.Get("inventory_key").(string),
131+
InventoryValue: d.Get("inventory_value").(string),
132+
TagSchema: d.Get("tag_schema").(string),
133+
DynamicTags: d.Get("dynamic_tags").(bool),
108134
Name: d.Get("name").(string),
109135
Suppressed: d.Get("suppressed").(bool),
110136
Tags: resourceToStringArray(d.Get("tags").([]interface{})),
@@ -146,6 +172,10 @@ func resourceToCSEInventoryEntityGroupConfiguration(d *schema.ResourceData) (CSE
146172
Group: d.Get("group").(string),
147173
InventoryType: d.Get("inventory_type").(string),
148174
InventorySource: d.Get("inventory_source").(string),
175+
InventoryKey: d.Get("inventory_key").(string),
176+
InventoryValue: d.Get("inventory_value").(string),
177+
TagSchema: d.Get("tag_schema").(string),
178+
DynamicTags: d.Get("dynamic_tags").(bool),
149179
Name: d.Get("name").(string),
150180
Suppressed: d.Get("suppressed").(bool),
151181
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: 7 additions & 2 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"
1413
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+
- `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.
2930
- `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)