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

feat(apigatewayv2-integrations): sqs integrations #29646

Merged
merged 31 commits into from
Feb 10, 2025

Conversation

badmintoncryer
Copy link
Contributor

@badmintoncryer badmintoncryer commented Mar 29, 2024

Issue # (if applicable)

Closes #24785.

Reason for this change

HTTP API supports AWS service integrations with SQS but CDK does not support this.

Description of changes

Added HttpSqsIntegration class

Description of how you validated changes

I've added both unit and integ tests.

Checklist


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

@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Mar 29, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team March 29, 2024 04:21
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review April 1, 2024 02:49

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@badmintoncryer badmintoncryer marked this pull request as ready for review April 1, 2024 03:07
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 1, 2024
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I really like the thought put in here to default values and abstracting away some of the parameters you know users will need every time. I have a few questions/comments inline regarding the contract. I'm not sure it's quite right but this is a great start.

*
* @default HttpIntegrationSubtype.SQS_SEND_MESSAGE
*/
readonly subtype?: apigwv2.HttpIntegrationSubtype;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since only a couple of these are relevant here, I think that this isn't quite the right type to use here. Of the 10 values, only 4 work.

Additionally, per the comments above where you mention that certain arns need to be added based off the subtype here, I think that these props aren't quite the right contract in general. For instance, in the case that this subtype is START_EXECUTION, the parameter mapping shouldn't be optional because it must include at least the StateMachineArn.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, I actually went back and read through the SubTypes more and it looks like the subtypes listed in the parameterMapping docstring above don't start with SQS_ so those comments don't mesh with the ones here in subType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm really sorry for describing crazy comments for parameterMapping.
I have updated it and could you please re-confirm it?

Copy link

@chriswilty chriswilty May 20, 2024

Choose a reason for hiding this comment

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

Why not narrow down the type to the sane choices? Ah damn, it's an enum...

type PickEnum<T, K extends T> = {
	[P in keyof K]: P extends K ? P : never;
};

type HttpSqsIntegrationProps = {
  readonly subtype: PickEnum<HttpIntegrationSubtype,
		| HttpIntegrationSubtype.SQS_SEND_MESSAGE
		| HttpIntegrationSubtype.SQS_RECEIVE_MESSAGE
		| HttpIntegrationSubtype.SQS_DELETE_MESSAGE
		| HttpIntegrationSubtype.SQS_PURGE_QUEUE
	>;
	readonly parameterMapping?: ParameterMapping;
};

Would that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chriswilty Thank you for your suggestion.
This PickEnum type will work correctly in TypeScript. However, it may not function properly when converted to other languages using jsii.
For example, I believe even TypeScript's union types couldn't be used in CDK.

I would like to check with the maintainer if it is usable.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, I think we can keep this since there's validation below that checks the subtype values.

*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html
*
* @default - specify only `StateMachineArn`
Copy link
Contributor

Choose a reason for hiding this comment

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

Below in the code you're using this.props.queue.queueUrl so this doesn't seem accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it.

*
* @default - specify only `StateMachineArn`
*/
readonly parameterMapping?: apigwv2.ParameterMapping;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these parameter mappings typically defined or can they be whatever the user adds here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default parameter mappings are based on this docs.
I defined only required parameter such as QueueUrl for SQS_SEND_MESSAGE.

If a user wants to set optional parameters or change the values of required parameters, it is assumed that they will provide a custom-defined parameterMapping.

Is this response addressing your question? Please feel free to correct me if my understanding is incorrect.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 10, 2024
@mergify mergify bot dismissed TheRealAmazonKendra’s stale review April 13, 2024 13:29

Pull request has been modified.

@badmintoncryer
Copy link
Contributor Author

@TheRealAmazonKendra Thank you for your review! I deeply apologize for the nonsensical comments regarding the parameterMappings. (It seems that it was likely mistakenly copied from somewhere...)
I have corrected the relevant sections and responded to your questions. Please review at your convenience.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 13, 2024
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@badmintoncryer badmintoncryer force-pushed the 24785-sqsSendMessageIntegration branch from d3c3c88 to d8a7760 Compare June 3, 2024 15:07
GavinZZ
GavinZZ previously approved these changes Feb 6, 2025
*
* @default HttpIntegrationSubtype.SQS_SEND_MESSAGE
*/
readonly subtype?: apigwv2.HttpIntegrationSubtype;
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, I think we can keep this since there's validation below that checks the subtype values.

Copy link
Contributor

mergify bot commented Feb 6, 2025

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).

@GavinZZ
Copy link
Contributor

GavinZZ commented Feb 6, 2025

Going to approve on behalf of Kendra since this PR has been sitting here for almost half a year.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 6, 2025
Copy link
Contributor

mergify bot commented Feb 6, 2025

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).

Copy link
Contributor

mergify bot commented Feb 7, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify mergify bot dismissed GavinZZ’s stale review February 7, 2025 19:41

Pull request has been modified.

GavinZZ
GavinZZ previously approved these changes Feb 7, 2025
@GavinZZ
Copy link
Contributor

GavinZZ commented Feb 7, 2025

@badmintoncryer can you fix the linting errors when available?

@mergify mergify bot dismissed GavinZZ’s stale review February 7, 2025 22:24

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 7, 2025
@badmintoncryer
Copy link
Contributor Author

@GavinZZ Thank you for your approval. I've fixed linting errors.

Copy link
Contributor

mergify bot commented Feb 10, 2025

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).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 10, 2025
Copy link
Contributor

mergify bot commented Feb 10, 2025

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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: dbd315a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

mergify bot commented Feb 10, 2025

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).

@mergify mergify bot merged commit 775c009 into aws:main Feb 10, 2025
20 checks passed
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2025
@badmintoncryer badmintoncryer deleted the 24785-sqsSendMessageIntegration branch February 10, 2025 22:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apigatewayv2-integrations: Add support for SQS-SendMessage integration
6 participants