Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added two new construct patterns: aws-events-rule-kinesisstream and aws-events-rule-kinesisfirehose-s3 #92

Merged
merged 12 commits into from
Oct 26, 2020

Conversation

aijunpeng
Copy link
Contributor

Issue #, if available:
#59: aws-events-rule-kinesisstream
#72: aws-events-rule-kinesisfirehose-s3

Description of changes:

  1. Added a new construct pattern aws-events-rule-kinesisstream that implements an Amazon CloudWatch Events rule to send data to an Amazon Kinesis Data Stream.
  2. Added a new construct pattern aws-events-rule-kinesisfirehose-s3 that implements an Amazon CloudWatch Events rule to send data to an Amazon Kinesis Data Firehose delivery stream connected to an Amazon S3 bucket.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: ed925a7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@hnishar hnishar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, few minor comments, the main one is missing recommended CW Alarms for Kinesisstream pattern, check any other aws-kinesisstreams-* pattern for reference.

Here is a minimal deployable pattern definition in Typescript:

``` javascript
const { EventsRuleToKinesisFirehoseToS3, EventsRuleToKinesisFirehoseToS3Props } from '@aws-solutions-constructs/aws-events-rule-kinesisfirehose-s3';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change const to import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


const props: EventsRuleToKinesisFirehoseToS3Props = {
eventRuleProps: {
description: 'event rule props',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is description necessary ? It might be nice to have, but this example is for a minimal deployable pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed description

|eventsRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for Events Rule|
|kinesisFirehoseRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)|Returns an instance of the iam.Role created by the construct for Kinesis Data Firehose delivery stream|
|kinesisFirehoseLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for Kinesis Data Firehose delivery stream|
|firehoseToS3|[`aws_solutions_constructs.aws-kinesisfirehose-s3`](https://docs.aws.amazon.com/solutions/latest/constructs/aws-kinesisfirehose-s3.html)|Returns an instance of aws-kinesisfirehose-s3 construct created by the construct|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we should expose the underlying solutions construct, as long all the resulting CDK objects are available as properties, IMO this exposes the unnecessary complexity to the user, especially the whole point of these patterns is to abstract away these complexities from the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I exposed firehoseToS3 instance as a property of the construct is because that I want to make it easier to access properties of firehoseToS3 that aren’t exposed in the firehoseToS3 construct without having to changing the firehoseToS3 construct itself. Since firehoseToS3 is the base construct rather than the top construct, it won’t affect user experience. But I got your point and updated the code per request.

public readonly kinesisFirehoseRole: iam.Role;
public readonly s3Bucket?: s3.Bucket;
public readonly s3LoggingBucket?: s3.Bucket;
public readonly firehoseToS3: KinesisFirehoseToS3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above. Recommend removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

})
};

// Add the kinese event source mapping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the comment, probably "Set up the events rule props"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

},
"dotnet": {
"namespace": "Amazon.Constructs.AWS.eventsrulekinesisstream",
"packageId": "Amazon.Constructs.AWS.eventsrulekinesisstream",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pascal case EventsRuleKinesisStream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png"
},
"python": {
"distName": "aws-solutions-constructs.aws-events-rule-kinesisstream",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use kinesis-stream instead of kinesisstream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

},
"python": {
"distName": "aws-solutions-constructs.aws-events-rule-kinesisstream",
"module": "aws_solutions_constructs.aws_events_rule_kinesisstream"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use kinesis_stream instead of kinesisstream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
};

const constructStack = new EventsRuleToKinesisStream(this, 'test-events-rule-kinesis-stream', props);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove const constructStack =

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


new EventsRuleToKinesisStream(stack, 'test-events-rule-kinesis-stream', props);

app.synth();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend adding an integ test for existing stream i.e. existingStreamObj

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@aijunpeng
Copy link
Contributor Author

Addressed all the items that were raised in the code review and pushed the new code changes. Please take a look at the new changes. Thanks!

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: 714ba6b
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: b2472a1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@hnishar hnishar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor updates requested and a name change for the kinsesisstream pattern, hope that's not an issue.

const props: EventsRuleToKinesisFirehoseToS3Props = {
eventRuleProps: {
schedule: events.Schedule.rate(cdk.Duration.minutes(5))
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing bracket }

    const props: EventsRuleToKinesisFirehoseToS3Props = {
      eventRuleProps: {
      schedule: events.Schedule.rate(cdk.Duration.minutes(5))
      }
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


``` javascript
import { EventsRuleToKinesisFirehoseToS3, EventsRuleToKinesisFirehoseToS3Props } from '@aws-solutions-constructs/aws-events-rule-kinesisfirehose-s3';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for cdk.Duration, please add import * as cdk from '@aws-cdk/core';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

``` javascript
import { EventsRuleToKinesisFirehoseToS3, EventsRuleToKinesisFirehoseToS3Props } from '@aws-solutions-constructs/aws-events-rule-kinesisfirehose-s3';

const props: EventsRuleToKinesisFirehoseToS3Props = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this code is copied into the cdk init app the props variable collides with the existing one, please change the props variable name to eventsRuleToKinesisFirehoseToS3Props here and on line 37

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


``` typescript
import {EventsRuleToKinesisStream, EventsRuleToKinesisStreamProps} from "@aws-solutions-constructs/aws-events-rule-kinesisstream";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for cdk.Duration, please add import * as cdk from '@aws-cdk/core';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

``` typescript
import {EventsRuleToKinesisStream, EventsRuleToKinesisStreamProps} from "@aws-solutions-constructs/aws-events-rule-kinesisstream";

const props: EventsRuleToKinesisStreamProps = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this code is copied into the cdk init app the props variable collides with the existing one, please change the props variable name to eventsRulesKinesisstreamProps here and on line 37

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,83 @@
{
"name": "@aws-solutions-constructs/aws-events-rule-kinesisstream",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest name change of the pattern from aws-events-rule-kinesisstream to aws-events-rule-kinesisstreams to be consistent with other aws-kinesisstreams-* patterns in the library, it will entain changing the directory names as well, sorry should have caught it the first time..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

…nts-rule-kinesisstream to aws-events-rule-kinesisstreams
@aijunpeng
Copy link
Contributor Author

Pushed code changes per PR feedback.

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: e544a87
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: d374ed1
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: 4d30b8c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@hnishar hnishar merged commit ddc0f03 into awslabs:master Oct 26, 2020
@hnishar
Copy link
Contributor

hnishar commented Oct 26, 2020

Thanks for the contribution, these will be published in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants