-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CR updates; refactor to service package and update test coverage
- Loading branch information
Showing
12 changed files
with
529 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:new-data-source | ||
aws_kinesis_stream_consumer | ||
``` | ||
|
||
```release-note:new-resource | ||
aws_kinesis_stream_consumer | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/kinesis" | ||
) | ||
|
||
// StreamConsumerByARN returns the stream consumer corresponding to the specified ARN. | ||
// Returns nil if no stream consumer is found. | ||
func StreamConsumerByARN(conn *kinesis.Kinesis, arn string) (*kinesis.ConsumerDescription, error) { | ||
input := &kinesis.DescribeStreamConsumerInput{ | ||
ConsumerARN: aws.String(arn), | ||
} | ||
|
||
output, err := conn.DescribeStreamConsumer(input) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, nil | ||
} | ||
|
||
return output.ConsumerDescription, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/kinesis" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/kinesis/finder" | ||
) | ||
|
||
const ( | ||
StreamConsumerStatusNotFound = "NotFound" | ||
StreamConsumerStatusUnknown = "Unknown" | ||
) | ||
|
||
// StreamConsumerStatus fetches the StreamConsumer and its Status | ||
func StreamConsumerStatus(conn *kinesis.Kinesis, arn string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
consumer, err := finder.StreamConsumerByARN(conn, arn) | ||
|
||
if err != nil { | ||
return nil, StreamConsumerStatusUnknown, err | ||
} | ||
|
||
if consumer == nil { | ||
return nil, StreamConsumerStatusNotFound, nil | ||
} | ||
|
||
return consumer, aws.StringValue(consumer.ConsumerStatus), nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package waiter | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/service/kinesis" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
const ( | ||
StreamConsumerCreatedTimeout = 5 * time.Minute | ||
StreamConsumerDeletedTimeout = 5 * time.Minute | ||
) | ||
|
||
// StreamConsumerCreated waits for an Stream Consumer to return Active | ||
func StreamConsumerCreated(conn *kinesis.Kinesis, arn string) (*kinesis.ConsumerDescription, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{kinesis.ConsumerStatusCreating}, | ||
Target: []string{kinesis.ConsumerStatusActive}, | ||
Refresh: StreamConsumerStatus(conn, arn), | ||
Timeout: StreamConsumerCreatedTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if v, ok := outputRaw.(*kinesis.ConsumerDescription); ok { | ||
return v, err | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
// StreamConsumerDeleted waits for a Stream Consumer to be deleted | ||
func StreamConsumerDeleted(conn *kinesis.Kinesis, arn string) (*kinesis.ConsumerDescription, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{kinesis.ConsumerStatusDeleting}, | ||
Target: []string{}, | ||
Refresh: StreamConsumerStatus(conn, arn), | ||
Timeout: StreamConsumerDeletedTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if v, ok := outputRaw.(*kinesis.ConsumerDescription); ok { | ||
return v, err | ||
} | ||
|
||
return nil, err | ||
} |
Oops, something went wrong.