Skip to content

Commit 0b67395

Browse files
tpoundsMathieu Lecarme
authored and
Mathieu Lecarme
committed
Use DescribeStreamSummary in place of ListStreams in kinesis output (influxdata#4864)
1 parent bf3a8ee commit 0b67395

File tree

3 files changed

+11
-37
lines changed

3 files changed

+11
-37
lines changed

Gopkg.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
[[constraint]]
1818
name = "github.com/aws/aws-sdk-go"
19-
version = "1.14.8"
19+
version = "1.15.54"
2020

2121
[[constraint]]
2222
name = "github.com/bsm/sarama-cluster"

plugins/outputs/kinesis/kinesis.go

+7-33
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package kinesis
22

33
import (
44
"log"
5-
"os"
65
"time"
76

87
"github.com/aws/aws-sdk-go/aws"
@@ -115,17 +114,11 @@ func (k *KinesisOutput) Description() string {
115114
return "Configuration for the AWS Kinesis output."
116115
}
117116

118-
func checkstream(l []*string, s string) bool {
119-
// Check if the StreamName exists in the slice returned from the ListStreams API request.
120-
for _, stream := range l {
121-
if *stream == s {
122-
return true
123-
}
117+
func (k *KinesisOutput) Connect() error {
118+
if k.Partition == nil {
119+
log.Print("E! kinesis : Deprecated paritionkey configuration in use, please consider using outputs.kinesis.partition")
124120
}
125-
return false
126-
}
127121

128-
func (k *KinesisOutput) Connect() error {
129122
// We attempt first to create a session to Kinesis using an IAMS role, if that fails it will fall through to using
130123
// environment variables, and then Shared Credentials.
131124
if k.Debug {
@@ -145,29 +138,10 @@ func (k *KinesisOutput) Connect() error {
145138
configProvider := credentialConfig.Credentials()
146139
svc := kinesis.New(configProvider)
147140

148-
KinesisParams := &kinesis.ListStreamsInput{
149-
Limit: aws.Int64(100),
150-
}
151-
152-
resp, err := svc.ListStreams(KinesisParams)
153-
154-
if err != nil {
155-
log.Printf("E! kinesis: Error in ListSteams API call : %+v \n", err)
156-
}
157-
158-
if checkstream(resp.StreamNames, k.StreamName) {
159-
if k.Debug {
160-
log.Printf("E! kinesis: Stream Exists")
161-
}
162-
k.svc = svc
163-
return nil
164-
} else {
165-
log.Printf("E! kinesis : You have configured a StreamName %+v which does not exist. exiting.", k.StreamName)
166-
os.Exit(1)
167-
}
168-
if k.Partition == nil {
169-
log.Print("E! kinesis : Deprecated paritionkey configuration in use, please consider using outputs.kinesis.partition")
170-
}
141+
_, err := svc.DescribeStreamSummary(&kinesis.DescribeStreamSummaryInput{
142+
StreamName: aws.String(k.StreamName),
143+
})
144+
k.svc = svc
171145
return err
172146
}
173147

0 commit comments

Comments
 (0)