-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(pipes-targets): add API destination #30756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly integ coverage, LGTM overall
packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts
Outdated
Show resolved
Hide resolved
}); | ||
|
||
const connection = new cdk.aws_events.Connection(stack, 'MyConnection', { | ||
authorization: cdk.aws_events.Authorization.apiKey('x-api-key', secret.secretValue), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also curious to see what happens when you also set the same header in ApiDestination.headerParameters
. It's either ignored or overrides the authorization
, but I think we should probably warn the user either way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below with screenshot.
ec3dd80
to
6f969cc
Compare
@nmussy Here's the result from the Lambda logs. The |
packages/@aws-cdk/aws-pipes-targets-alpha/lib/api-destination.ts
Outdated
Show resolved
Hide resolved
* The headers to send as part of the request invoking the EventBridge API destination. | ||
* | ||
* The headers are merged with the headers from the API destination. | ||
* If there are conflicts, the headers from the API destination take precedence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nmussy I added this note about precedence. From the logs we can see that x-api-key
is abc123
, not apiKeyFromHeaderParams
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is enough to indicate to users which value will take precedence. Is there somewhere we can print a warning when there are two identical headers provided, which explicitly lets the user know that the value is being set twice, and which of those values it's using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@redwheeler3 jfyi. I think it's worth mentioning in Docs and/or Console about precedence regarding conflicting headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, and sorry for the delay! Overall seems good to me, just a few things to note before moving forward with these changes.
* The headers to send as part of the request invoking the EventBridge API destination. | ||
* | ||
* The headers are merged with the headers from the API destination. | ||
* If there are conflicts, the headers from the API destination take precedence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is enough to indicate to users which value will take precedence. Is there somewhere we can print a warning when there are two identical headers provided, which explicitly lets the user know that the value is being set twice, and which of those values it's using?
packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts
Outdated
Show resolved
Hide resolved
I'm not quite sure how to do this. There could be any number of custom headers, no? |
I believe that's the case, yeah. I was thinking some check like iterating through the header keys to see which overlap, like turning them into a set and taking the intersection type of operation. Then if we know the
|
e7ace5e
to
214765b
Compare
Pull request has been modified.
I'd prefer to do this in a follow-up PR. What do you think? I think the logic could get messy/complicated. I think the documentation note is sufficient for now. |
I do think we should include these changes in this PR, unless there are any other extra changes you wanted to add that might make the logic more confusing to follow. But ideally, including them in this PR means the logic is bundled together from the get-go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! Aside from my comment above regarding including the warning, just one more minor nit in the README.
I'm a little confused on what this would look like. An |
214765b
to
43588e0
Compare
Pull request has been modified.
If I'm understanding the code correctly, the area of conflict is between |
I think I would need to change
to
Excuse my naïveté. Good with that? |
43588e0
to
66133ad
Compare
@moelasmar updated with your feedback—thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems all good to me, thanks for the quick responses on feedback! Just adding in one quick typehint that I missed before, and will wait to make sure the tests pass.
packages/@aws-cdk/aws-pipes-targets-alpha/lib/api-destination.ts
Outdated
Show resolved
Hide resolved
@mergify update |
✅ Branch has been successfully updated |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
Add EventBridge API destination as a Pipes target.
CloudFormation groups EventBridge API destination with API Gateway REST API
as PipeTargetHttpParameters, but I think separating them here similar to aws-event-targets
makes more sense, as API Gateway requires
stage
,path
, andmethod
(see here).