Skip to content

Commit

Permalink
Merge pull request #11652 from blake-wilson/add-flink-support
Browse files Browse the repository at this point in the history
Support Apache Flink runtime for Kinesis Analytics
  • Loading branch information
breathingdust authored Oct 21, 2020
2 parents 73f9101 + 1885acc commit db46e45
Show file tree
Hide file tree
Showing 10 changed files with 7,254 additions and 3 deletions.
20 changes: 20 additions & 0 deletions aws/internal/service/kinesisanalyticsv2/finder/finder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package finder

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/kinesisanalyticsv2"
)

// ApplicationByName returns the application corresponding to the specified name.
func ApplicationByName(conn *kinesisanalyticsv2.KinesisAnalyticsV2, name string) (*kinesisanalyticsv2.ApplicationDetail, error) {
input := &kinesisanalyticsv2.DescribeApplicationInput{
ApplicationName: aws.String(name),
}

output, err := conn.DescribeApplication(input)
if err != nil {
return nil, err
}

return output.ApplicationDetail, nil
}
31 changes: 31 additions & 0 deletions aws/internal/service/kinesisanalyticsv2/waiter/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package waiter

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/kinesisanalyticsv2"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/kinesisanalyticsv2/finder"
)

const (
applicationStatusNotFound = "NotFound"
applicationStatusUnknown = "Unknown"
)

// ApplicationStatus fetches the Application and its Status
func ApplicationStatus(conn *kinesisanalyticsv2.KinesisAnalyticsV2, name string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
application, err := finder.ApplicationByName(conn, name)

if tfawserr.ErrCodeEquals(err, kinesisanalyticsv2.ErrCodeResourceNotFoundException) {
return nil, applicationStatusNotFound, nil
}

if err != nil {
return nil, applicationStatusUnknown, err
}

return application, aws.StringValue(application.ApplicationStatus), nil
}
}
26 changes: 26 additions & 0 deletions aws/internal/service/kinesisanalyticsv2/waiter/waiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package waiter

import (
"time"

"github.com/aws/aws-sdk-go/service/kinesisanalyticsv2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

// ApplicationDeleted waits for an Application to return Deleted
func ApplicationDeleted(conn *kinesisanalyticsv2.KinesisAnalyticsV2, name string, timeout time.Duration) (*kinesisanalyticsv2.ApplicationDetail, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{kinesisanalyticsv2.ApplicationStatusDeleting},
Target: []string{},
Refresh: ApplicationStatus(conn, name),
Timeout: timeout,
}

outputRaw, err := stateConf.WaitForState()

if v, ok := outputRaw.(*kinesisanalyticsv2.ApplicationDetail); ok {
return v, err
}

return nil, err
}
3 changes: 2 additions & 1 deletion aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,10 @@ func Provider() *schema.Provider {
"aws_iot_topic_rule": resourceAwsIotTopicRule(),
"aws_iot_role_alias": resourceAwsIotRoleAlias(),
"aws_key_pair": resourceAwsKeyPair(),
"aws_kinesis_analytics_application": resourceAwsKinesisAnalyticsApplication(),
"aws_kinesisanalyticsv2_application": resourceAwsKinesisAnalyticsV2Application(),
"aws_kinesis_firehose_delivery_stream": resourceAwsKinesisFirehoseDeliveryStream(),
"aws_kinesis_stream": resourceAwsKinesisStream(),
"aws_kinesis_analytics_application": resourceAwsKinesisAnalyticsApplication(),
"aws_kinesis_video_stream": resourceAwsKinesisVideoStream(),
"aws_kms_alias": resourceAwsKmsAlias(),
"aws_kms_external_key": resourceAwsKmsExternalKey(),
Expand Down
Loading

0 comments on commit db46e45

Please sign in to comment.