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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

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.

*
* @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
@badmintoncryer badmintoncryer force-pushed the 24785-sqsSendMessageIntegration branch from d8a7760 to 73ad0d0 Compare June 3, 2024 15:08
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@badmintoncryer badmintoncryer changed the title feat(apigatewayv2-integrations): sqs integration feat(apigatewayv2-integrations): sqs integrations Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. 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
4 participants