Skip to content

feat(events): API Destinations#13729

Merged
mergify[bot] merged 35 commits intoaws:masterfrom
msimpsonnz:msimpson/feat-evb-api-dest
Feb 16, 2022
Merged

feat(events): API Destinations#13729
mergify[bot] merged 35 commits intoaws:masterfrom
msimpsonnz:msimpson/feat-evb-api-dest

Conversation

@msimpsonnz
Copy link
Copy Markdown
Contributor

@msimpsonnz msimpsonnz commented Mar 22, 2021

Adds Connection and ApiDestination constructs in Events, and an ApiDestination target in Events Targets. Can be used to do arbitrary HTTP calls.

Fixes #13729


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Mar 22, 2021

@github-actions github-actions bot added the @aws-cdk/aws-events Related to CloudWatch Events label Mar 22, 2021
@msimpsonnz
Copy link
Copy Markdown
Contributor Author

@rix0rrr It would be great to get a first review on this make sure I’m in the right path

Copy link
Copy Markdown
Contributor

@DaWyz DaWyz left a comment

Choose a reason for hiding this comment

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

Nice job @msimpsonnz . I added a few comments on your PR. I'm no aws-cdk maintainer so feel free to act on them if they make sense to you or ask confirmation to @rix0rrr if needed.

Copy link
Copy Markdown

@SvenBayer SvenBayer left a comment

Choose a reason for hiding this comment

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

@msimpsonnz, your pull request is pretty cool. I tried your code but could not get it working to add an Api Destination to my EventBridge Rule. However, I realised that the CloudWatchLogGroup is an IRuleTarget that wraps LogGroup that contains all the information. I would suggest to use here the same pattern and to wrap ApiDestination in aws-events with ApiDestination in aws-event-targets.

After my experiment I got it working. You can see my suggested changes in my comments. I hope they are helpful.

input: this.props.event,
targetResource: this.connection,
httpParameters,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since we add the role as required property, we should assign it here and return it in this bind method.

};

return {
arn: this.connection.connectionArn,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since we add the TargetBaseProps, we should return ...bindBaseTargetConfig(this.props), as in CloudWatchLogGroup

rix0rrr
rix0rrr previously requested changes Jun 4, 2021
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Thanks for the submission!

There are a couple of small things that I'd like to see addressed (most of them already pointed out by @DaWyz), and I guess I'm not too fond of the name "API Destination" because it seems it could have been a lot more descriptive (how about HttpDestination?) but I guess we're bound to whatever EventBridge chose as their terminology...

*
* @default none
*/
readonly headerParameters?: { [key: string]: string };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are these here? Aren't they API gateway specific?

Doesn't it make more sense to separate this out into API Gateway destinations and "other" destinations?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

HttpParameters (headers/body/querystrings) on EventBridge targets are re-used for both ApiGateway and ApiDestinations targets

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jun 7, 2021

@mergify mergify bot dismissed rix0rrr’s stale review June 7, 2021 23:08

Pull request has been modified.

@msimpsonnz
Copy link
Copy Markdown
Contributor Author

Thanks for the submission!

There are a couple of small things that I'd like to see addressed (most of them already pointed out by @DaWyz), and I guess I'm not too fond of the name "API Destination" because it seems it could have been a lot more descriptive (how about HttpDestination?) but I guess we're bound to whatever EventBridge chose as their terminology...

Thanks @rix0rrr, I'm happy to rename but this is what EventBridge had chosen, I wasn't sure if changing this might affect functionality down the road.

@msimpsonnz
Copy link
Copy Markdown
Contributor Author

Thanks @DaWyz and @SvenBayer
This was work in progress, I wanted to check I was on the right path with the different auth methods
I've updated and this now has a working deployment with a role created if you don't supply one

@mergify mergify bot dismissed rix0rrr’s stale review June 16, 2021 07:36

Pull request has been modified.

@nhuray
Copy link
Copy Markdown

nhuray commented Aug 4, 2021

Thanks @msimpsonnz for that PR, it's really more convenient than dealing with the Cfn constructs !

Do we have an ETA for releasing it ?

/**
* The ARN of the connection to use for the API destination
*/
readonly connection: IConnection;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@rix0rrr I didn't find the documentation stating connection is optional. But in the AWS UI it's clearly required.
Screen Shot 2021-08-04 at 4 18 06 PM

apiDestinationName: 'apiDestinationName',
connection: connection,
invocationEndpoint: 'https://endpoint.com',
invocationRateLimit: Duration.seconds(10),
Copy link
Copy Markdown

@nhuray nhuray Aug 4, 2021

Choose a reason for hiding this comment

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

@msimpsonnz I'm confuse because you defined invocationRateLimit as number but you are passing Duration

  /**
   * The maximum number of requests per second to send to the HTTP invocation endpoint.
   * 
   * @default - None
   */
  readonly invocationRateLimit?: number

Is it a mistake ?

test.done();
},

// 'create connection with InvocationHttpParameters'(test: Test) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@msimpsonnz Does that test fails ?

@nikkipin
Copy link
Copy Markdown

Hey @msimpsonnz are you still interested in finishing this? I can provide a round of code review...

@msimpsonnz
Copy link
Copy Markdown
Contributor Author

@nikp yeah I am keen to continue, just wanted a review on path forward as felt there is a bit to do with Cfn generators

@rix0rrr
Copy link
Copy Markdown
Contributor

rix0rrr commented Feb 15, 2022

Hope you're okay with me getting this over the finish line @msimpsonnz. Thanks for all the work so far!

rix0rrr
rix0rrr previously approved these changes Feb 15, 2022
@mergify mergify bot dismissed rix0rrr’s stale review February 15, 2022 15:57

Pull request has been modified.

rix0rrr
rix0rrr previously approved these changes Feb 15, 2022
@mergify mergify bot dismissed rix0rrr’s stale review February 16, 2022 10:48

Pull request has been modified.

rix0rrr
rix0rrr previously approved these changes Feb 16, 2022
@mergify mergify bot dismissed rix0rrr’s stale review February 16, 2022 12:01

Pull request has been modified.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 16, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 928ac2d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit 2adbc14 into aws:master Feb 16, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 16, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Adds `Connection` and `ApiDestination` constructs in Events, and an `ApiDestination` target in Events Targets. Can be used to do arbitrary HTTP calls.

Fixes aws#13729 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@aws-cdk/aws-events Related to CloudWatch Events

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants