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): add missing WebSocketIntegration props #29566

Merged
merged 9 commits into from
Mar 22, 2024

Conversation

nmussy
Copy link
Contributor

@nmussy nmussy commented Mar 21, 2024

Issue # (if applicable)

None as far as I can tell

Reason for this change

I was looking at the WebSocket integration to get a feel for #29562, and noticed a couple of missing properties

Description of changes

  • Added support for timeout and contentHandling
  • Minor copy-pasta fixes in documentation and test description

Description of how you validated changes

I've added unit tests to check these optional properties. I've also updated and verified the following integrations tests:

  • integ.lambda.ts:
    • ContentHandlingStrategy and TimeoutInMillis are both correctly set
$ aws apigatewayv2 get-integration --api-id bu24s9i8t0 --integration-id fxqec8c
{
    "ConnectionType": "INTERNET",
    "ContentHandlingStrategy": "CONVERT_TO_TEXT",
    "IntegrationId": "fxqec8c",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:637423343434:function:WebSocketApiInteg-DefaultHandler604DF7AC-GSQYxsiaKjkz/invocations",
    "PassthroughBehavior": "WHEN_NO_MATCH",
    "PayloadFormatVersion": "1.0",
    "RequestTemplates": {},
    "TimeoutInMillis": 10000
}
  • integ.aws.ts:
    • ContentHandlingStrategy, TemplateSelectionExpression, TimeoutInMillis, PassthroughBehavior, and RequestParameters are all correctly set
$ aws apigatewayv2 get-integration --api-id qp17tw07w3 --integration-id hycmjxb
{
    "ConnectionType": "INTERNET",
    "ContentHandlingStrategy": "CONVERT_TO_BINARY",
    "CredentialsArn": "arn:aws:iam::637423343434:role/integ-aws-websocket-integrat-ApiGatewayRoleD2518903-i80lztfxo5XI",
    "IntegrationId": "hycmjxb",
    "IntegrationMethod": "POST",
    "IntegrationResponseSelectionExpression": "${integration.response.statuscode}",
    "IntegrationType": "AWS",
    "IntegrationUri": "arn:aws:apigateway:us-east-1:dynamodb:action/PutItem",
    "PassthroughBehavior": "WHEN_NO_TEMPLATES",
    "PayloadFormatVersion": "1.0",
    "RequestParameters": {
        "integration.request.header.Content-Type": "'application/x-www-form-urlencoded'"
    },
    "RequestTemplates": {
        "application/json": "{\"TableName\":\"MyTable\",\"Item\":{\"id\":{\"S\":\"$context.requestId\"}}}"
    },
    "TemplateSelectionExpression": "\\$default",
    "TimeoutInMillis": 10000
}

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team March 21, 2024 06:53
@github-actions github-actions bot added p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Mar 21, 2024
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 March 21, 2024 09:05

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

@nmussy nmussy marked this pull request as ready for review March 21, 2024 09: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 Mar 21, 2024

You can also set additional properties to change the behavior of your integration, such as `contentHandling`.
See [Working with binary media types for WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-develop-binary-media-types.html).
Copy link
Contributor

Choose a reason for hiding this comment

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

worth adding timeout here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are already a few existing optional props on top of the two I've added:
https://github.com/nmussy/aws-cdk/blob/58625787bd0027bb375a760271c5fed957ac6966/packages/%40aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.aws.ts#L44-L61

timeout feels pretty minor, especially because its default is already maxed out. Most of them are already shown in the "AWS WebSocket Integration" example, I could add the timeout there?

https://github.com/nmussy/aws-cdk/blob/58625787bd0027bb375a760271c5fed957ac6966/packages/aws-cdk-lib/aws-apigatewayv2-integrations/README.md?plain=1#L289-L305

Copy link
Contributor

@msambol msambol left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @nmussy !

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Mar 21, 2024
@shikha372 shikha372 self-assigned this Mar 21, 2024
Copy link
Contributor

mergify bot commented Mar 21, 2024

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-maintainer-review This PR needs a review from a Core Team Member label Mar 21, 2024
Copy link
Contributor

mergify bot commented Mar 21, 2024

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 Mar 21, 2024

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

@shikha372
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Mar 22, 2024

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 46c0bcf
  • 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 Mar 22, 2024

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 7534dcd into aws:main Mar 22, 2024
9 checks passed
@nmussy nmussy deleted the feat-apigatewayv2-missing-websocket-props branch March 23, 2024 14:27
ahammond pushed a commit to ahammond/aws-cdk that referenced this pull request Mar 26, 2024
### Issue # (if applicable)

None as far as I can tell

### Reason for this change

I was looking at the WebSocket integration to get a feel for aws#29562, and noticed a couple of missing properties

### Description of changes

* Added support for `timeout` and `contentHandling`
* Minor copy-pasta fixes in documentation and test description

### Description of how you validated changes

I've added unit tests to check these optional properties. I've also updated and verified the following integrations tests:

* `integ.lambda.ts`:
  * `ContentHandlingStrategy` and `TimeoutInMillis` are both correctly set
```sh
$ aws apigatewayv2 get-integration --api-id bu24s9i8t0 --integration-id fxqec8c
{
    "ConnectionType": "INTERNET",
    "ContentHandlingStrategy": "CONVERT_TO_TEXT",
    "IntegrationId": "fxqec8c",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:637423343434:function:WebSocketApiInteg-DefaultHandler604DF7AC-GSQYxsiaKjkz/invocations",
    "PassthroughBehavior": "WHEN_NO_MATCH",
    "PayloadFormatVersion": "1.0",
    "RequestTemplates": {},
    "TimeoutInMillis": 10000
}
```
* `integ.aws.ts`:
  * `ContentHandlingStrategy`, `TemplateSelectionExpression`, `TimeoutInMillis`,  `PassthroughBehavior`, and `RequestParameters` are all correctly set
 
```sh
$ aws apigatewayv2 get-integration --api-id qp17tw07w3 --integration-id hycmjxb
{
    "ConnectionType": "INTERNET",
    "ContentHandlingStrategy": "CONVERT_TO_BINARY",
    "CredentialsArn": "arn:aws:iam::637423343434:role/integ-aws-websocket-integrat-ApiGatewayRoleD2518903-i80lztfxo5XI",
    "IntegrationId": "hycmjxb",
    "IntegrationMethod": "POST",
    "IntegrationResponseSelectionExpression": "${integration.response.statuscode}",
    "IntegrationType": "AWS",
    "IntegrationUri": "arn:aws:apigateway:us-east-1:dynamodb:action/PutItem",
    "PassthroughBehavior": "WHEN_NO_TEMPLATES",
    "PayloadFormatVersion": "1.0",
    "RequestParameters": {
        "integration.request.header.Content-Type": "'application/x-www-form-urlencoded'"
    },
    "RequestTemplates": {
        "application/json": "{\"TableName\":\"MyTable\",\"Item\":{\"id\":{\"S\":\"$context.requestId\"}}}"
    },
    "TemplateSelectionExpression": "\\$default",
    "TimeoutInMillis": 10000
}
```

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants