Skip to content

Commit af0e6df

Browse files
author
Pedro Montiel
committed
Merge branch 'master' into INVS-1146_Entity_Group_Inventory_enhancements
# Conflicts: # CHANGELOG.md
2 parents 1aa2ebe + b632e21 commit af0e6df

22 files changed

+1983
-39
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
## 2.25.1 (Unreleased)
1+
## 2.26.1 (Unreleased)
2+
FEATURES:
3+
* **New Resource:** sumologic_cse_tag_schema (GH-575)
4+
* **New Resource:** sumologic_cse_context_action (GH-573)
5+
26
ENHANCEMENTS:
37
* resource/sumologic_cse_inventory_entity_group_configuration: Add new fields to support enhanced functionality. (GH-495)
48

59
DEPRECATIONS:
610
* resource/sumologic_cse_inventory_entity_group_configuration: Deprecated `groups` in favor of `inventory_key`, `inventory_value`. (GH-495)
711

12+
## 2.26.0 (September 7, 2023)
13+
FEATURES:
14+
* **New Resource:** sumologic_muting_schedule (GH-569)
15+
* resource/sumologic_monitor: Added support for associating tags with a Monitor.
16+
817
## 2.25.0 (August 8, 2023)
918
FEATURES:
1019
* **New Resource:** sumologic_metrics_search (GH-528)
@@ -52,7 +61,6 @@ DEPRECATIONS:
5261

5362
* resource/sumologic_monitor: Deprecated `burn_rate_threshold` and `time_range` in favor of `burn_rate` inside `slo_burn_rate_condition` block (GH-499)
5463

55-
5664
## 2.21.0 (February 27, 2023)
5765
FEATURES:
5866
* **New Resource:** sumologic_cse_first_seen_rule (GH-476)

sumologic/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func Provider() terraform.ResourceProvider {
4343
},
4444
},
4545
ResourcesMap: map[string]*schema.Resource{
46+
"sumologic_cse_tag_schema": resourceSumologicCSETagSchema(),
47+
"sumologic_cse_context_action": resourceSumologicCSEContextAction(),
4648
"sumologic_cse_automation": resourceSumologicCSEAutomation(),
4749
"sumologic_cse_entity_normalization_configuration": resourceSumologicCSEEntityNormalizationConfiguration(),
4850
"sumologic_cse_inventory_entity_group_configuration": resourceSumologicCSEInventoryEntityGroupConfiguration(),
@@ -94,6 +96,7 @@ func Provider() terraform.ResourceProvider {
9496
"sumologic_connection": resourceSumologicConnection(),
9597
"sumologic_monitor": resourceSumologicMonitorsLibraryMonitor(),
9698
"sumologic_monitor_folder": resourceSumologicMonitorsLibraryFolder(),
99+
"sumologic_muting_schedule": resourceSumologicMutingSchedulesLibraryMutingSchedule(),
97100
"sumologic_slo": resourceSumologicSLO(),
98101
"sumologic_slo_folder": resourceSumologicSLOLibraryFolder(),
99102
"sumologic_ingest_budget_v2": resourceSumologicIngestBudgetV2(),

sumologic/resource_sumologic_connection.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ func resourceSumologicConnection() *schema.Resource {
5555
Elem: &schema.Schema{
5656
Type: schema.TypeString,
5757
},
58-
Optional: true,
59-
Default: map[string]interface{}{},
58+
Optional: true,
59+
Default: map[string]interface{}{},
60+
Sensitive: true,
6061
},
6162
"custom_headers": {
6263
Type: schema.TypeMap,

sumologic/resource_sumologic_cse_automation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ func resourceSumologicCSEAutomationRead(d *schema.ResourceData, meta interface{}
6464

6565
CSEAutomation, err := c.GetCSEAutomation(id)
6666
if err != nil {
67-
log.Printf("[WARN] CSE Custom Entity Type not found when looking by id: %s, err: %v", id, err)
67+
log.Printf("[WARN] CSE Automation not found when looking by id: %s, err: %v", id, err)
6868

6969
}
7070

7171
if CSEAutomation == nil {
72-
log.Printf("[WARN] CSE Custom Entity Type not found, removing from state: %v - %v", id, err)
72+
log.Printf("[WARN] CSE Automation not found, removing from state: %v - %v", id, err)
7373
d.SetId("")
7474
return nil
7575
}

sumologic/resource_sumologic_cse_automation_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ func testAccCSEAutomationDestroy(s *terraform.State) error {
4747
client := testAccProvider.Meta().(*Client)
4848

4949
for _, rs := range s.RootModule().Resources {
50-
if rs.Type != "sumologic_cse_custom_entity_type" {
50+
if rs.Type != "sumologic_cse_automation" {
5151
continue
5252
}
5353

5454
if rs.Primary.ID == "" {
55-
return fmt.Errorf("CSE Custom Entity Type Config destruction check: CSE Custom Entity Type Config ID is not set")
55+
return fmt.Errorf("CSE Automation destruction check: CSE Automation ID is not set")
5656
}
5757

5858
s, err := client.GetCSEAutomation(rs.Primary.ID)
5959
if err != nil {
6060
return fmt.Errorf("Encountered an error: " + err.Error())
6161
}
6262
if s != nil {
63-
return fmt.Errorf("entity Custom Entity Type still exists")
63+
return fmt.Errorf("automation still exists")
6464
}
6565
}
6666
return nil
@@ -86,7 +86,7 @@ func testCheckCSEAutomationExists(n string, Automation *CSEAutomation) resource.
8686
}
8787

8888
if rs.Primary.ID == "" {
89-
return fmt.Errorf("entity Custom Entity Type ID is not set")
89+
return fmt.Errorf("automation ID is not set")
9090
}
9191

9292
c := testAccProvider.Meta().(*Client)
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
package sumologic
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
5+
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
6+
"log"
7+
)
8+
9+
func resourceSumologicCSEContextAction() *schema.Resource {
10+
return &schema.Resource{
11+
Create: resourceSumologicCSEContextActionCreate,
12+
Read: resourceSumologicCSEContextActionRead,
13+
Delete: resourceSumologicCSEContextActionDelete,
14+
Update: resourceSumologicCSEContextActionUpdate,
15+
Importer: &schema.ResourceImporter{
16+
State: schema.ImportStatePassthrough,
17+
},
18+
19+
Schema: map[string]*schema.Schema{
20+
"name": {
21+
Type: schema.TypeString,
22+
Required: true,
23+
},
24+
"type": {
25+
Type: schema.TypeString,
26+
Optional: true,
27+
ValidateFunc: validation.All(
28+
validation.StringIsNotEmpty,
29+
validation.StringInSlice([]string{"URL", "QUERY"}, false)),
30+
},
31+
"template": {
32+
Type: schema.TypeString,
33+
Optional: true,
34+
},
35+
"ioc_types": {
36+
Type: schema.TypeList,
37+
Required: true,
38+
Elem: &schema.Schema{
39+
Type: schema.TypeString,
40+
ValidateFunc: validation.All(validation.StringIsNotEmpty, validation.StringInSlice([]string{"ASN", "DOMAIN", "HASH", "IP_ADDRESS", "MAC_ADDRESS", "PORT", "RECORD_PROPERTY", "URL"}, false)),
41+
},
42+
},
43+
"entity_types": {
44+
Type: schema.TypeList,
45+
Optional: true,
46+
Elem: &schema.Schema{
47+
Type: schema.TypeString,
48+
ValidateFunc: validation.StringIsNotEmpty,
49+
},
50+
},
51+
"record_fields": {
52+
Type: schema.TypeList,
53+
Optional: true,
54+
Elem: &schema.Schema{
55+
Type: schema.TypeString,
56+
ValidateFunc: validation.StringIsNotEmpty,
57+
},
58+
},
59+
"all_record_fields": {
60+
Type: schema.TypeBool,
61+
Optional: true,
62+
Default: true,
63+
},
64+
"enabled": {
65+
Type: schema.TypeBool,
66+
Optional: true,
67+
Default: true,
68+
},
69+
},
70+
}
71+
}
72+
73+
func resourceSumologicCSEContextActionRead(d *schema.ResourceData, meta interface{}) error {
74+
c := meta.(*Client)
75+
76+
var CSEContextAction *CSEContextAction
77+
id := d.Id()
78+
79+
CSEContextAction, err := c.GetCSEContextAction(id)
80+
if err != nil {
81+
log.Printf("[WARN] CSE Context Action not found when looking by id: %s, err: %v", id, err)
82+
83+
}
84+
85+
if CSEContextAction == nil {
86+
log.Printf("[WARN] CSE Context Action not found, removing from state: %v - %v", id, err)
87+
d.SetId("")
88+
return nil
89+
}
90+
91+
d.Set("name", CSEContextAction.Name)
92+
d.Set("type", CSEContextAction.Type)
93+
d.Set("template", CSEContextAction.Template)
94+
d.Set("ioc_types", CSEContextAction.IocTypes)
95+
d.Set("entity_types", CSEContextAction.EntityTypes)
96+
d.Set("record_fields", CSEContextAction.RecordFields)
97+
d.Set("all_record_fields", CSEContextAction.AllRecordFields)
98+
d.Set("enabled", CSEContextAction.Enabled)
99+
100+
return nil
101+
}
102+
103+
func resourceSumologicCSEContextActionDelete(d *schema.ResourceData, meta interface{}) error {
104+
c := meta.(*Client)
105+
106+
return c.DeleteCSEContextAction(d.Id())
107+
108+
}
109+
110+
func resourceSumologicCSEContextActionCreate(d *schema.ResourceData, meta interface{}) error {
111+
c := meta.(*Client)
112+
113+
if d.Id() == "" {
114+
id, err := c.CreateCSEContextAction(CSEContextAction{
115+
Name: d.Get("name").(string),
116+
Type: d.Get("type").(string),
117+
Template: d.Get("template").(string),
118+
IocTypes: resourceFieldsToStringArray(d.Get("ioc_types").([]interface{})),
119+
EntityTypes: resourceFieldsToStringArray(d.Get("entity_types").([]interface{})),
120+
RecordFields: resourceFieldsToStringArray(d.Get("record_fields").([]interface{})),
121+
AllRecordFields: d.Get("all_record_fields").(bool),
122+
Enabled: d.Get("enabled").(bool),
123+
})
124+
125+
if err != nil {
126+
return err
127+
}
128+
129+
d.SetId(id)
130+
}
131+
132+
return resourceSumologicCSEContextActionRead(d, meta)
133+
}
134+
135+
func resourceSumologicCSEContextActionUpdate(d *schema.ResourceData, meta interface{}) error {
136+
CSEContextAction, err := resourceToCSEContextAction(d)
137+
if err != nil {
138+
return err
139+
}
140+
c := meta.(*Client)
141+
if err = c.UpdateCSEContextAction(CSEContextAction); err != nil {
142+
return err
143+
}
144+
145+
return resourceSumologicCSEContextActionRead(d, meta)
146+
}
147+
148+
func resourceToCSEContextAction(d *schema.ResourceData) (CSEContextAction, error) {
149+
id := d.Id()
150+
if id == "" {
151+
return CSEContextAction{}, nil
152+
}
153+
154+
return CSEContextAction{
155+
ID: id,
156+
Name: d.Get("name").(string),
157+
Type: d.Get("type").(string),
158+
Template: d.Get("template").(string),
159+
IocTypes: resourceFieldsToStringArray(d.Get("ioc_types").([]interface{})),
160+
EntityTypes: resourceFieldsToStringArray(d.Get("entity_types").([]interface{})),
161+
RecordFields: resourceFieldsToStringArray(d.Get("record_fields").([]interface{})),
162+
AllRecordFields: d.Get("all_record_fields").(bool),
163+
Enabled: d.Get("enabled").(bool),
164+
}, nil
165+
}

0 commit comments

Comments
 (0)