Skip to content

Commit 3ce783d

Browse files
committed
Merge branch 'master' into sumo.170432.permission.api.resource
2 parents 45a3b88 + 7d76c91 commit 3ce783d

28 files changed

+1477
-76
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
SUMOLOGIC_ENVIRONMENT: ${{ secrets.SUMOLOGIC_ENVIRONMENT }}
9292
SUMOLOGIC_TEST_BUCKET_NAME: ${{ secrets.SUMOLOGIC_TEST_BUCKET_NAME }}
9393
SUMOLOGIC_TEST_ROLE_ARN: ${{ secrets.SUMOLOGIC_TEST_ROLE_ARN }}
94+
SUMOLOGIC_TEST_GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.SUMOLOGIC_TEST_GOOGLE_APPLICATION_CREDENTIALS }}
9495

9596
# disable go test timeout. We rely on GitHub action timeout.
9697
run: |

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
## 2.12.0 (Unreleased)
1+
## 2.12.1 (Unreleased)
2+
3+
ENHANCEMENTS:
4+
* Add support for importing folder resource (GH-345)
5+
* Allow AtLeastOnce resolution conditions for Metrics monitors (GH-346)
6+
7+
## 2.12.0 (February 7, 2022)
8+
9+
FEATURES:
10+
* **New Resource:** Gcp Metrics Source `sumologic_gcp_metrics_source` (GH-329, 332)
11+
12+
ENHANCEMENTS:
13+
* Add support for OTLP in HTTP source resource (GH-335)
14+
* Add backoff on http 429s (GH-338)
15+
* Add `domain` field to the dashboard resource (GH-341)
16+
17+
BUG FIXES:
18+
* Fix to allow more than one topology_label for Dashboard resource (GH-336)
19+
* sumologic_cse_log_mapping split_index as int (GH-333)
220

321
## 2.11.5 (December 14, 2021)
422

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ Then run `terraform init` to initialize it.
5353

5454
In order to run the full suite of Acceptance tests, run `make testacc`.
5555

56-
*Note:* Acceptance tests *create real resources*, and often cost money to run. The environment variables `SUMOLOGIC_ACCESSID`, `SUMOLOGIC_ACCESSKEY`, and `SUMOLOGIC_ENVIRONMENT` must also be set for acceptance tests to work properly.
56+
*Note:*
57+
- Acceptance tests *create real resources*, and often cost money to run. The environment variables `SUMOLOGIC_ACCESSID`, `SUMOLOGIC_ACCESSKEY`, and `SUMOLOGIC_ENVIRONMENT` must also be set for acceptance tests to work properly.
58+
- Environment variable `SUMOLOGIC_TEST_GOOGLE_APPLICATION_CREDENTIALS` must be set for gcp metrics acceptance tests to work properly (ex. below).
59+
- export SUMOLOGIC_TEST_GOOGLE_APPLICATION_CREDENTIALS=`cat /path/to/service_acccount.json`
60+
- Set Environment variable `SUMOLOGIC_ENABLE_GCP_METRICS_ACC_TESTS` to false, to disable acceptance test for Gcp Metrics.
5761

5862
[0]: https://help.sumologic.com/Manage/Security/Access-Keys
5963
[1]: https://help.sumologic.com/APIs/General_API_Information/Sumo_Logic_Endpoints_and_Firewall_Security

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/go-errors/errors v1.4.0
1010
github.com/go-test/deep v1.0.7 // indirect
1111
github.com/hashicorp/go-hclog v0.16.2 // indirect
12+
github.com/hashicorp/go-retryablehttp v0.7.0
1213
github.com/hashicorp/go-uuid v1.0.2 // indirect
1314
github.com/hashicorp/hcl v1.0.0 // indirect
1415
github.com/hashicorp/terraform-config-inspect v0.0.0-20210625153042-09f34846faab // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uP
224224
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
225225
github.com/hashicorp/go-plugin v1.3.0 h1:4d/wJojzvHV1I4i/rrjVaeuyxWrLzDE1mDCyDy8fXS8=
226226
github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0=
227+
github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4=
228+
github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
227229
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
228230
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
229231
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=

sumologic/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func Provider() terraform.ResourceProvider {
6868
"sumologic_cloudtrail_source": resourceSumologicGenericPollingSource(),
6969
"sumologic_elb_source": resourceSumologicGenericPollingSource(),
7070
"sumologic_cloudfront_source": resourceSumologicGenericPollingSource(),
71+
"sumologic_gcp_metrics_source": resourceSumologicGenericPollingSource(),
7172
"sumologic_cloud_to_cloud_source": resourceSumologicCloudToCloudSource(),
7273
"sumologic_metadata_source": resourceSumologicMetadataSource(),
7374
"sumologic_cloudsyslog_source": resourceSumologicCloudsyslogSource(),
@@ -91,6 +92,7 @@ func Provider() terraform.ResourceProvider {
9192
"sumologic_password_policy": resourceSumologicPasswordPolicy(),
9293
"sumologic_saml_configuration": resourceSumologicSamlConfiguration(),
9394
"sumologic_kinesis_metrics_source": resourceSumologicKinesisMetricsSource(),
95+
"sumologic_kinesis_log_source": resourceSumologicKinesisLogSource(),
9496
"sumologic_token": resourceSumologicToken(),
9597
"sumologic_policies": resourceSumologicPolicies(),
9698
"sumologic_hierarchy": resourceSumologicHierarchy(),

sumologic/resource_sumologic_cse_log_mapping.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sumologic
22

33
import (
4+
"fmt"
45
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
56
"log"
67
)
@@ -100,7 +101,7 @@ func resourceSumologicCSELogMapping() *schema.Resource {
100101
Optional: true,
101102
},
102103
"split_index": {
103-
Type: schema.TypeString,
104+
Type: schema.TypeInt,
104105
Optional: true,
105106
},
106107
"field_join": {
@@ -354,7 +355,7 @@ func resourceToCSELogMappingField(data interface{}) CSELogMappingField {
354355
field.AlternateValues = resourceStringArrayToStringArray(fieldObj["alternate_values"].([]interface{}))
355356
field.TimeZone = fieldObj["time_zone"].(string)
356357
field.SplitDelimiter = fieldObj["split_delimiter"].(string)
357-
field.SplitIndex = fieldObj["split_index"].(string)
358+
field.SplitIndex = fmt.Sprint(fieldObj["split_index"].(int))
358359
field.FieldJoin = resourceStringArrayToStringArray(fieldObj["field_join"].([]interface{}))
359360
field.JoinDelimiter = fieldObj["join_delimiter"].(string)
360361
field.FormatParameters = resourceStringArrayToStringArray(fieldObj["format_parameters"].([]interface{}))

sumologic/resource_sumologic_cse_log_mapping_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestAccSumologicSCELogMapping_create(t *testing.T) {
3434
AlternateValues: []string{"altValue"},
3535
TimeZone: "UTC",
3636
SplitDelimiter: ",",
37-
SplitIndex: "index",
37+
SplitIndex: "0",
3838
FieldJoin: []string{"and"},
3939
JoinDelimiter: "",
4040
FormatParameters: []string{"param"},
@@ -90,7 +90,7 @@ func TestAccSumologicSCELogMapping_update(t *testing.T) {
9090
AlternateValues: []string{"altValue"},
9191
TimeZone: "UTC",
9292
SplitDelimiter: ",",
93-
SplitIndex: "index",
93+
SplitIndex: "0",
9494
FieldJoin: []string{"and"},
9595
JoinDelimiter: "",
9696
FormatParameters: []string{"param"},

sumologic/resource_sumologic_dashboard.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func resourceSumologicDashboard() *schema.Resource {
6969
Elem: &schema.Resource{
7070
Schema: map[string]*schema.Schema{
7171
"data": {
72-
Type: schema.TypeList,
72+
Type: schema.TypeSet,
7373
Required: true,
7474
Elem: &schema.Resource{
7575
Schema: map[string]*schema.Schema{
@@ -91,6 +91,10 @@ func resourceSumologicDashboard() *schema.Resource {
9191
},
9292
},
9393
},
94+
"domain": {
95+
Type: schema.TypeString,
96+
Optional: true,
97+
},
9498
"refresh_interval": {
9599
Type: schema.TypeInt,
96100
Optional: true,
@@ -132,7 +136,7 @@ func resourceSumologicDashboard() *schema.Resource {
132136
ValidateFunc: validation.StringInSlice([]string{"Light", "Dark"}, true),
133137
Default: "Light",
134138
},
135-
// TODO Do we need this field in terraform?
139+
// TODO: This field is NOT supported. Remove it.
136140
"coloring_rule": {
137141
Type: schema.TypeList,
138142
Optional: true,
@@ -705,6 +709,7 @@ func resourceToDashboard(d *schema.ResourceData) Dashboard {
705709
Description: d.Get("description").(string),
706710
FolderId: d.Get("folder_id").(string),
707711
TopologyLabelMap: topologyLabel,
712+
Domain: d.Get("domain").(string),
708713
RefreshInterval: d.Get("refresh_interval").(int),
709714
TimeRange: timeRange,
710715
Panels: panels,
@@ -948,9 +953,9 @@ func getTimeRangeBoundary(tfRangeBoundary map[string]interface{}) interface{} {
948953
}
949954

950955
func getTopologyLabel(tfTopologyLabel map[string]interface{}) *TopologyLabel {
951-
if items := tfTopologyLabel["data"].([]interface{}); len(items) == 1 {
956+
if items := tfTopologyLabel["data"].(*schema.Set); items.Len() >= 1 {
952957
labelMap := make(map[string][]string)
953-
for _, item := range items {
958+
for _, item := range items.List() {
954959
dataItem := item.(map[string]interface{})
955960
key := dataItem["label"].(string)
956961
itemValues := dataItem["values"].([]interface{})
@@ -960,6 +965,7 @@ func getTopologyLabel(tfTopologyLabel map[string]interface{}) *TopologyLabel {
960965
}
961966
labelMap[key] = values
962967
}
968+
963969
return &TopologyLabel{
964970
Data: labelMap,
965971
}
@@ -1101,6 +1107,9 @@ func setDashboard(d *schema.ResourceData, dashboard *Dashboard) error {
11011107
if err := d.Set("folder_id", dashboard.FolderId); err != nil {
11021108
return err
11031109
}
1110+
if err := d.Set("domain", dashboard.Domain); err != nil {
1111+
return err
1112+
}
11041113
if err := d.Set("refresh_interval", dashboard.RefreshInterval); err != nil {
11051114
return err
11061115
}
@@ -1139,10 +1148,11 @@ func setDashboard(d *schema.ResourceData, dashboard *Dashboard) error {
11391148
}
11401149

11411150
log.Println("=====================================================================")
1142-
log.Printf("title: %+v\n", d.Get("title"))
1143-
log.Printf("description: %+v\n", d.Get("description"))
1144-
log.Printf("folder_id: %+v\n", d.Get("folder_id"))
1151+
log.Printf("title: %s\n", d.Get("title"))
1152+
log.Printf("description: %s\n", d.Get("description"))
1153+
log.Printf("folder_id: %s\n", d.Get("folder_id"))
11451154
log.Printf("topology_label_map: %+v\n", d.Get("topology_label_map"))
1155+
log.Printf("domain: %s\n", d.Get("domain"))
11461156
log.Printf("time_range: %+v\n", d.Get("time_range"))
11471157
log.Printf("panel: %+v\n", d.Get("panel"))
11481158
log.Printf("layout: %+v\n", d.Get("layout"))

sumologic/resource_sumologic_dashboard_test.go

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ import (
1111
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1212
)
1313

14+
var firstLabelKey = "service"
15+
var secondLabelKey = "env"
16+
var topologyLabel = TopologyLabel{
17+
Data: map[string][]string{
18+
firstLabelKey: {"collection-proxy"},
19+
secondLabelKey: {"dev", "prod"},
20+
},
21+
}
22+
1423
func TestAccSumologicDashboard_basic(t *testing.T) {
1524
testNameSuffix := acctest.RandString(16)
1625
title := "terraform_test_dashboard_" + testNameSuffix
@@ -41,8 +50,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
4150
description := "Test dashboard description"
4251
theme := "Dark"
4352
refreshInterval := 120
44-
topologyLabel := "service"
45-
topologyLabelValue := "collection-proxy"
53+
domain := "aws"
4654
literalRangeName := "today"
4755
textPanel := TextPanel{
4856
Key: "text-panel-001",
@@ -77,7 +85,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
7785
Steps: []resource.TestStep{
7886
{
7987
Config: dashboardCreateConfig(title, description, theme, refreshInterval,
80-
topologyLabel, topologyLabelValue, literalRangeName, textPanel, layout, variable),
88+
topologyLabel, domain, literalRangeName, textPanel, layout, variable),
8189
Check: resource.ComposeTestCheckFunc(
8290
testAccCheckDashboardExists("sumologic_dashboard.tf_crud_test", &dashboard, t),
8391
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -89,9 +97,9 @@ func TestAccSumologicDashboard_create(t *testing.T) {
8997
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
9098
"theme", theme),
9199
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
92-
"topology_label_map.0.data.0.label", topologyLabel),
100+
"topology_label_map.0.data.#", "2"),
93101
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
94-
"topology_label_map.0.data.0.values.0", topologyLabelValue),
102+
"domain", domain),
95103
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
96104
"time_range.#", "1"),
97105
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -124,8 +132,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
124132
description := "Test dashboard description"
125133
theme := "Dark"
126134
refreshInterval := 120
127-
topologyLabel := "service"
128-
topologyLabelValue := "collection-proxy"
135+
domain := "aws"
129136
literalRangeName := "today"
130137
textPanel := TextPanel{
131138
Key: "text-panel-001",
@@ -155,7 +162,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
155162
// updated config
156163
newTheme := "Light"
157164
newRefreshInterval := 300
158-
newTopologyLabelValue := "collection-cluster"
165+
newFirstLabelValue := "collection-cluster"
166+
updatedDomain := "app"
159167
newLiteralRangeName := "week"
160168
searchPanel := SumoSearchPanel{
161169
Key: "search-panel-001",
@@ -207,7 +215,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
207215
Steps: []resource.TestStep{
208216
{
209217
Config: dashboardCreateConfig(title, description, theme, refreshInterval,
210-
topologyLabel, topologyLabelValue, literalRangeName, textPanel, layout, csvVariable),
218+
topologyLabel, domain, literalRangeName, textPanel, layout, csvVariable),
211219
Check: resource.ComposeTestCheckFunc(
212220
testAccCheckDashboardExists("sumologic_dashboard.tf_crud_test", &dashboard, t),
213221
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -217,7 +225,9 @@ func TestAccSumologicDashboard_update(t *testing.T) {
217225
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
218226
"theme", theme),
219227
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
220-
"topology_label_map.0.data.0.values.0", topologyLabelValue),
228+
"topology_label_map.0.data.#", "2"),
229+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
230+
"domain", domain),
221231
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
222232
"time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name",
223233
literalRangeName),
@@ -237,8 +247,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
237247
},
238248
{
239249
Config: dashboardUpdateConfig(title, description, newTheme, newRefreshInterval,
240-
topologyLabel, newTopologyLabelValue, newLiteralRangeName, textPanel, searchPanel,
241-
newLayout, newVariables),
250+
firstLabelKey, newFirstLabelValue, updatedDomain, newLiteralRangeName, textPanel,
251+
searchPanel, newLayout, newVariables),
242252
Check: resource.ComposeTestCheckFunc(
243253
testAccCheckDashboardExists("sumologic_dashboard.tf_crud_test", &dashboard, t),
244254
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -248,7 +258,9 @@ func TestAccSumologicDashboard_update(t *testing.T) {
248258
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
249259
"theme", newTheme),
250260
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
251-
"topology_label_map.0.data.0.values.0", newTopologyLabelValue),
261+
"topology_label_map.0.data.#", "1"),
262+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
263+
"domain", updatedDomain),
252264
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
253265
"time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name",
254266
newLiteralRangeName),
@@ -391,7 +403,7 @@ func dashboardImportConfig(title string) string {
391403
}
392404

393405
func dashboardCreateConfig(title string, description string, theme string, refreshInterval int,
394-
topologyLabel string, topologyLabelValue string, rangeName string, textPanel TextPanel,
406+
topologyLabel TopologyLabel, domain string, rangeName string, textPanel TextPanel,
395407
layout GridLayout, variable Variable) string {
396408

397409
return fmt.Sprintf(`
@@ -407,7 +419,12 @@ func dashboardCreateConfig(title string, description string, theme string, refre
407419
label = "%s"
408420
values = ["%s"]
409421
}
422+
data {
423+
label = "%s"
424+
values = ["%s", "%s"]
425+
}
410426
}
427+
domain = "%s"
411428
time_range {
412429
begin_bounded_time_range {
413430
from {
@@ -448,16 +465,18 @@ func dashboardCreateConfig(title string, description string, theme string, refre
448465
hide_from_ui = false
449466
}
450467
}`,
451-
title, description, refreshInterval, theme, topologyLabel, topologyLabelValue, rangeName,
452-
textPanel.Key, textPanel.Title, textPanel.Text,
468+
title, description, refreshInterval, theme, firstLabelKey, topologyLabel.Data[firstLabelKey][0],
469+
secondLabelKey, topologyLabel.Data[secondLabelKey][0], topologyLabel.Data[secondLabelKey][1],
470+
domain, rangeName, textPanel.Key, textPanel.Title, textPanel.Text,
453471
layout.LayoutStructures[0].Key, variable.Name, variable.DisplayName, variable.DefaultValue,
454472
variable.SourceDefinition.(CsvVariableSourceDefinition).Values,
455473
)
456474
}
457475

458476
func dashboardUpdateConfig(title string, description string, theme string, refreshInterval int,
459-
topologyLabel string, topologyLabelValue string, rangeName string, textPanel TextPanel,
460-
searchPanel SumoSearchPanel, layout GridLayout, variables []Variable) string {
477+
topologyLabel string, topologyLabelValue string, domain string, rangeName string,
478+
textPanel TextPanel, searchPanel SumoSearchPanel, layout GridLayout,
479+
variables []Variable) string {
461480

462481
loqQuerySourceDef := variables[1].SourceDefinition.(LogQueryVariableSourceDefinition)
463482
csvSourceDef := variables[0].SourceDefinition.(CsvVariableSourceDefinition)
@@ -476,6 +495,7 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
476495
values = ["%s"]
477496
}
478497
}
498+
domain = "%s"
479499
time_range {
480500
begin_bounded_time_range {
481501
from {
@@ -558,8 +578,8 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
558578
hide_from_ui = false
559579
}
560580
}`,
561-
title, description, refreshInterval, theme, topologyLabel, topologyLabelValue, rangeName,
562-
textPanel.Key, textPanel.Title, textPanel.Text,
581+
title, description, refreshInterval, theme, topologyLabel, topologyLabelValue, domain,
582+
rangeName, textPanel.Key, textPanel.Title, textPanel.Text,
563583
searchPanel.Key, searchPanel.Title, searchPanel.Description, searchPanel.Queries[0].QueryString,
564584
searchPanel.Queries[0].QueryKey,
565585
layout.LayoutStructures[0].Key, layout.LayoutStructures[1].Key,

0 commit comments

Comments
 (0)