Skip to content

Commit ec0fcb0

Browse files
authored
Merge pull request #691 from SumoLogic/adding_index_Id_in_scheduled_view
SUMO-248024:
2 parents 971d6c2 + 651ae55 commit ec0fcb0

10 files changed

+79
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
DEPRECATIONS:
33
* resource_sumologic_ingest_budget : Deprecated in favour of `resource_sumologic_ingest_budget_v2`.
44

5+
## 2.31.5
6+
ENHANCEMENTS:
7+
* Added *index_id* attribute to sumologic_scheduled_view. (GH-691)
8+
* Added support for configuring sumologic_data_forwarding_rule for sumologic_scheduled_view. (GH-691)
9+
510
## 2.31.4 (September 19, 2024)
611
* **New Resource:** sumologic_data_forwarding_destination (GH-678)
712
* **New Resource:** sumologic_data_forwarding_rule (GH-688)

sumologic/resource_sumologic_data_forwarding_destination.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func resourceSumologicDataForwardingDestination() *schema.Resource {
6161
"enabled": {
6262
Type: schema.TypeBool,
6363
Optional: true,
64-
Default: false,
6564
},
6665
"s3_region": {
6766
Type: schema.TypeString,

sumologic/resource_sumologic_data_forwarding_rule.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ func resourceSumologicDataForwardingRule() *schema.Resource {
3333
"enabled": {
3434
Type: schema.TypeBool,
3535
Optional: true,
36-
Default: true,
3736
},
3837
"file_format": {
3938
Type: schema.TypeString,
4039
Optional: true,
41-
Default: "{index}_{day}_{hour}_{minute}_{second}",
4240
},
4341
"payload_schema": {
4442
Type: schema.TypeString,

sumologic/resource_sumologic_data_forwarding_rule_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestAccSumologicDataForwardingRule_basic(t *testing.T) {
6060
testAccCheckDataForwardingRuleExists(),
6161
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "index_id", indexId),
6262
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "destination_id", destinationId),
63-
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "enabled", "true"),
63+
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "enabled", "false"),
6464
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "file_format", "test/"),
6565
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "payload_schema", "builtInFields"),
6666
resource.TestCheckResourceAttr(dataForwardingRuleResourceName, "format", "json"),
@@ -227,7 +227,7 @@ func testAccSumologicDataForwardingRuleUpdateConfig() string {
227227
resource "sumologic_data_forwarding_rule" "test" {
228228
index_id = "%s"
229229
destination_id = "%s"
230-
enabled = true
230+
enabled = false
231231
file_format = "test/"
232232
payload_schema = "builtInFields"
233233
format = "json"

sumologic/resource_sumologic_scheduled_view.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func resourceSumologicScheduledView() *schema.Resource {
3737
ForceNew: true,
3838
ValidateFunc: validation.IsRFC3339Time,
3939
},
40+
"index_id": {
41+
Type: schema.TypeString,
42+
Optional: true,
43+
Computed: true,
44+
},
4045
"retention_period": {
4146
Type: schema.TypeInt,
4247
Optional: true,
@@ -76,6 +81,7 @@ func resourceSumologicScheduledViewCreate(d *schema.ResourceData, meta interface
7681
}
7782

7883
d.SetId(createdSview.ID)
84+
d.Set("index_id", createdSview.IndexId)
7985
d.Set("retention_period", createdSview.RetentionPeriod)
8086
}
8187

@@ -99,6 +105,7 @@ func resourceSumologicScheduledViewRead(d *schema.ResourceData, meta interface{}
99105
return nil
100106
}
101107

108+
d.Set("index_id", sview.IndexId)
102109
d.Set("query", sview.Query)
103110
d.Set("index_name", sview.IndexName)
104111
d.Set("start_time", sview.StartTime.Format(time.RFC3339))

sumologic/sumologic_data_forwarding_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *Client) DeleteDataForwardingRule(indexId string) error {
6262
type DataForwardingRule struct {
6363
IndexId string `json:"indexId"`
6464
DestinationId string `json:"destinationId"`
65-
Enabled bool `json:"enabled,omitempty"`
65+
Enabled bool `json:"enabled"`
6666
FileFormat string `json:"fileFormat,omitempty"`
6767
PayloadSchema string `json:"payloadSchema,omitempty"`
6868
Format string `json:"format,omitempty"`

sumologic/sumologic_scheduled_view.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (s *Client) UpdateScheduledView(sview ScheduledView) error {
5858

5959
type ScheduledView struct {
6060
ID string `json:"id,omitempty"`
61+
IndexId string `json:"indexId,omitempty"`
6162
Query string `json:"query"`
6263
IndexName string `json:"indexName"`
6364
StartTime time.Time `json:"startTime"`

website/docs/r/data_forwarding_destination.html.markdown

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ Provider to manage [Sumologic Data Forwarding Destination](https://help.sumologi
1212
```hcl
1313
resource "sumologic_data_forwarding_destination" "example_data_forwarding_destination" {
1414
destination_name = "df-destination"
15-
description = ""
15+
description = "some description"
1616
bucket_name = "df-bucket"
17-
region = "us-east-1"
18-
authentication_mode = "RoleBased"
19-
access_key_id = "accessKeyId"
20-
secret_access_key = "secretAccessKey"
21-
role_arn = "arn:aws:iam::some-valid-arn"
22-
encrypted = "false"
17+
s3_region = "us-east-1"
18+
authentication {
19+
type = "RoleBased"
20+
role_arn = "arn:aws:iam::your_arn"
21+
# access_key = "your access key"
22+
# secret_key = "your secret key"
23+
}
24+
s3_server_side_encryption = false
25+
enabled = true
2326
}
2427
```
2528
## Argument reference
@@ -29,12 +32,13 @@ The following arguments are supported:
2932
- `destination_name` - (Required) Name of the S3 data forwarding destination.
3033
- `description` - (Optional) Description of the S3 data forwarding destination.
3134
- `bucket_name` - (Required) The name of the Amazon S3 bucket.
32-
- `region` - (Optional) The region where the S3 bucket is located.
33-
- `authentication_mode` - (Required) AWS IAM authentication method used for access. Possible values are: 1. `AccessKey` 2. `RoleBased`
34-
- `access_key_id` - (Optional) The AWS Access ID to access the S3 bucket.
35-
- `secret_access_key` - (Optional) The AWS Secret Key to access the S3 bucket.
35+
- `s3_region` - (Optional) The region where the S3 bucket is located.
36+
- `type` - (Required) AWS IAM authentication method used for access. Possible values are: 1. `AccessKey` 2. `RoleBased`
37+
- `access_key` - (Optional) The AWS Access ID to access the S3 bucket.
38+
- `secret_key` - (Optional) The AWS Secret Key to access the S3 bucket.
3639
- `role_arn` - (Optional) The AWS Role ARN to access the S3 bucket.
37-
- `encrypted` - (Optional) Enable S3 server-side encryption.
40+
- `s3_server_side_encryption` - (Optional) Enable S3 server-side encryption.
41+
- `enabled` - (Optional) True when the data forwarding destination is enabled. Will be treated as _false_ if left blank.
3842

3943
The following attributes are exported:
4044

website/docs/r/data_forwarding_rule.html.markdown

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,61 @@ description: |-
99
Provider to manage [Sumologic Data Forwarding Rule](https://help.sumologic.com/docs/manage/data-forwarding/amazon-s3-bucket/#forward-datato-s3)
1010

1111
## Example Usage
12+
13+
For Partitions
1214
```hcl
15+
resource "sumologic_partition" "test_partition" {
16+
name = "testing_rule_partitions"
17+
routing_expression = "_sourcecategory=abc/Terraform"
18+
is_compliant = false
19+
retention_period = 30
20+
analytics_tier = "flex"
21+
}
22+
1323
resource "sumologic_data_forwarding_rule" "example_data_forwarding_rule" {
14-
index_id = "00000000024C6155"
15-
destination_id = "00000000000732AA"
16-
enabled = "true"
17-
file_format = "test/{index}/{day}/{hour}/{minute}"
18-
payload_schema = "builtInFields"
19-
format = "json"
24+
index_id = sumologic_partition.test_partition.id
25+
destination_id = "00000000000732AA"
26+
enabled = true
27+
file_format = "test/{index}/{day}/{hour}/{minute}"
28+
payload_schema = "builtInFields"
29+
format = "json"
30+
}
31+
```
32+
For Scheduled Views
33+
```hcl
34+
resource "sumologic_scheduled_view" "failed_connections" {
35+
index_name = "failed_connections"
36+
query = "_sourceCategory=fire | count"
37+
start_time = "2024-09-01T00:00:00Z"
38+
retention_period = 1
39+
lifecycle {
40+
prevent_destroy = true
41+
ignore_changes = [index_id]
42+
}
43+
}
44+
45+
resource "sumologic_data_forwarding_rule" "test_rule_sv" {
46+
index_id = sumologic_scheduled_view.failed_connections.index_id
47+
destination_id = sumologic_data_forwarding_destination.test_destination.id
48+
enabled = false
49+
file_format = "test/{index}"
50+
payload_schema = "raw"
51+
format = "text"
2052
}
2153
```
2254
## Argument reference
2355

2456
The following arguments are supported:
2557

26-
- `index_id` - (Required) The _id_ of the Partition or Scheduled View the rule applies to.
58+
- `index_id` - (Required) The *id* of the Partition or *index_id* of the Scheduled View the rule applies to.
2759
- `destination_id` - (Required) The data forwarding destination id.
28-
- `enabled` - (Required) True when the data forwarding rule is enabled.
29-
- `file_format` - (Optional) Specify the path prefix to a directory in the S3 bucket and how to format the file name.
60+
- `enabled` - (Optional) True when the data forwarding rule is enabled. Will be treated as _false_ if left blank.
61+
- `file_format` - (Optional) Specify the path prefix to a directory in the S3 bucket and how to format the file name. For possible values, kindly refer the point 6 in the [documentation](https://help.sumologic.com/docs/manage/data-forwarding/amazon-s3-bucket/#forward-datato-s3).
3062
- `payload_schema` - (Optional) Schema for the payload. Default value of the payload schema is _allFields_ for scheduled view, and _builtInFields_ for partition.
3163
_raw_ payloadSchema should be used in conjunction with _text_ format and vice versa.
3264
- `format` - (Optional) Format of the payload. Default format will be _csv_.
3365
_text_ format should be used in conjunction with _raw_ payloadSchema and vice versa.
66+
67+
The following attributes are exported:
68+
69+
- `id` - The Index ID of the data_forwarding_rule

website/docs/r/scheduled_view.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ QUERY
2323
retention_period = 365
2424
lifecycle {
2525
prevent_destroy = true
26+
ignore_changes = [index_id]
2627
}
2728
}
2829
```
@@ -44,6 +45,7 @@ The following arguments are supported:
4445
The following attributes are exported:
4546

4647
- `id` - The internal ID of the scheduled view.
48+
- `index_id` - The Index ID of the scheduled view. It remains unchanged during resource updates, and any manual modifications will be disregarded. While it’s not mandatory, we recommend to ignore this via `ignore_changes = [index_id]`.
4749

4850
## Import
4951
Scheduled Views can can be imported using the id. The list of scheduled views and their ids can be obtained using the Sumologic [scheduled views api][2].

0 commit comments

Comments
 (0)