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(apigateway): WebSocketIntegrationResponse implementation #29661

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

Conversation

nmussy
Copy link
Contributor

@nmussy nmussy commented Mar 31, 2024

Issue # (if applicable)

None as far as I could tell, related to #29562.

Reason for this change

While it is possible to use the L1 CfnIntegrationResponse construct, it's not trivial given the WebSocketRouteIntegration are currently bound to the WebSocketIntegration on the fly.

Description of changes

  • Added a basic L2 WebSocketIntegrationResponse construct
    • Gave two-way WebSocketIntegrations (capable of setting IntegrationResponse) a responses config prop, as well as a addResponse method. This allows me to check that there are no repeat responseKeys, and that returnResponse is active if there are responses set
    • An intermediate CustomResponseWebSocketRoute abstract class was created to isolate WebSocketLambdaIntegration, which does not support response customization
  • Added a WebSocketIntegrationResponseKey helper class to access common and to generate custom responseKeys

Also, and this was not the intent of this PR, but I found some missing properties for WebSocketMockIntegration while updating its integ test:

  • Added requestTemplates and templateSelectionExpression to the newly created WebSocketMockIntegrationProps

Description of how you validated changes

Unit tests were added/modified, and existing integration files were extended to include responses

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 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 labels Mar 31, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team March 31, 2024 14:13
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.

Comment on lines +294 to +295
// FIXME change to a warning?
throw new Error('Setting up integration responses without setting up returnResponse to true will have no effect, and is likely a mistake.');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure which is best here, as far as I can tell the web console (and thus I assume Cfn) allows the user to create responses, with a simple notice:

image

It does feel like quite a big pitfall though, I don't think an exception is unwarranted

Comment on lines -79 to -83
/**
* Integration response ID
*/
public readonly integrationResponseId?: string;

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 assume this was added in anticipation of an implementation of integration responses, but serves no purpose and cannot store multiple responses

Comment on lines 311 to 314
// FIXME any better way to generate a unique id?
Names.nodeUniqueId(this.integration.node) + slugify(responseProps.responseKey.key) + 'IntegrationResponse',
{ ...responseProps, integration: this.integration },
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure this is the best way to generate this ID, feedback would be appreciated

@nmussy
Copy link
Contributor Author

nmussy commented Apr 1, 2024

AWS_PROXY, implemented as WebSocketLambdaIntegration, is the only currently available integration type that does not support IntegrationResponse:

image

@aws-cdk-automation aws-cdk-automation dismissed their stale review April 1, 2024 16:44

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

@nmussy nmussy marked this pull request as ready for review April 2, 2024 10:25
@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 2, 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.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants