Skip to content

Commit 7af9046

Browse files
authored
Merge pull request #525 from SumoLogic/yuting-SUMO-221183-kinesis-log-auth
SUMO-221183 Fix the kinesis log third party reference
2 parents ca48c47 + 1bc9948 commit 7af9046

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

sumologic/resource_sumologic_kinesis_log_source.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ func resourceSumologicKinesisLogSource() *schema.Resource {
3636
}
3737
kinesisLogSource.Schema["authentication"] = &schema.Schema{
3838
Type: schema.TypeList,
39-
Required: true,
39+
Optional: true,
4040
MaxItems: 1,
4141
Elem: &schema.Resource{
4242
Schema: map[string]*schema.Schema{
4343
"type": {
4444
Type: schema.TypeString,
45-
Required: true,
45+
Optional: true,
46+
Default: "NoAuthentication",
4647
ValidateFunc: validation.StringInSlice([]string{"S3BucketAuthentication", "AWSRoleBasedAuthentication", "NoAuthentication"}, false),
4748
},
4849
"access_key": {
@@ -63,13 +64,14 @@ func resourceSumologicKinesisLogSource() *schema.Resource {
6364

6465
kinesisLogSource.Schema["path"] = &schema.Schema{
6566
Type: schema.TypeList,
66-
Required: true,
67+
Optional: true,
6768
MaxItems: 1,
6869
Elem: &schema.Resource{
6970
Schema: map[string]*schema.Schema{
7071
"type": {
7172
Type: schema.TypeString,
72-
Required: true,
73+
Optional: true,
74+
Default: "NoPathExpression",
7375
ValidateFunc: validation.StringInSlice([]string{"KinesisLogPath", "NoPathExpression"}, false),
7476
},
7577
"bucket_name": {
@@ -83,7 +85,6 @@ func resourceSumologicKinesisLogSource() *schema.Resource {
8385
"scan_interval": {
8486
Type: schema.TypeInt,
8587
Optional: true,
86-
Default: 300000,
8788
},
8889
},
8990
},
@@ -147,13 +148,6 @@ func resourceSumologicKinesisLogSourceRead(d *schema.ResourceData, meta interfac
147148
return nil
148149
}
149150

150-
kinesisLogResources := source.ThirdPartyRef.Resources
151-
path := getKinesisLogThirdPartyPathAttributes(kinesisLogResources)
152-
153-
if err := d.Set("path", path); err != nil {
154-
return err
155-
}
156-
157151
if err := resourceSumologicSourceRead(d, source.Source); err != nil {
158152
return fmt.Errorf("%s", err)
159153
}
@@ -202,19 +196,19 @@ func getKinesisLogPathSettings(d *schema.ResourceData) (KinesisLogPath, error) {
202196
path := paths[0].(map[string]interface{})
203197
switch pathType := path["type"].(string); pathType {
204198
case "KinesisLogPath":
205-
pathSettings.Type = pathType
199+
pathSettings.Type = "KinesisLogPath"
206200
pathSettings.BucketName = path["bucket_name"].(string)
207201
pathSettings.PathExpression = path["path_expression"].(string)
208202
pathSettings.ScanInterval = path["scan_interval"].(int)
209203
case "NoPathExpression":
210-
pathSettings.Type = pathType
204+
pathSettings.Type = "NoPathExpression"
211205
default:
212206
errorMessage := fmt.Sprintf("[ERROR] Unknown resourceType in path: %v", pathType)
213207
log.Print(errorMessage)
214208
return pathSettings, errors.New(errorMessage)
215209
}
216210
} else {
217-
return pathSettings, errors.New(fmt.Sprintf("[ERROR] no path specification in kinesis log Soruce"))
211+
pathSettings.Type = "NoPathExpression"
218212
}
219213
return pathSettings, nil
220214
}
@@ -246,6 +240,8 @@ func getKinesisLogAuthentication(d *schema.ResourceData) (PollingAuthentication,
246240
log.Print(errorMessage)
247241
return authSettings, errors.New(errorMessage)
248242
}
243+
} else {
244+
authSettings.Type = "NoAuthentication"
249245
}
250246

251247
return authSettings, nil

website/docs/r/kinesis_log_source.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ __IMPORTANT:__ The AWS credentials are stored in plain-text in the state. This i
6666
In addition to the common properties, the following arguments are supported:
6767

6868
- `content_type` - (Required) The content-type of the collected data. Details can be found in the [Sumologic documentation for hosted sources][1].
69-
- `authentication` - (Required) Authentication details for connecting to the S3 bucket.
69+
- `authentication` - (Optional) Authentication details for connecting to the S3 bucket.
7070
+ `type` - (Required) Must be either `S3BucketAuthentication` or `AWSRoleBasedAuthentication` or `NoAuthentication`
7171
+ `access_key` - (Required) Your AWS access key if using type `S3BucketAuthentication`
7272
+ `secret_key` - (Required) Your AWS secret key if using type `S3BucketAuthentication`
7373
+ `role_arn` - (Required) Your AWS role ARN if using type `AWSRoleBasedAuthentication`
74-
- `path` - (Required) The location of S3 bucket for failed Kinesis log data.
74+
- `path` - (Optional) The location of S3 bucket for failed Kinesis log data.
7575
+ `type` - (Required) Must be either `KinesisLogPath` or `NoPathExpression`
7676
+ `bucket_name` - (Optional) The name of the bucket. This is needed if using type `KinesisLogPath`.
7777
+ `path_expression` - (Optional) The path to the data. This is needed if using type `KinesisLogPath`. For Kinesis log source, it must include `http-endpoint-failed/`.

0 commit comments

Comments
 (0)