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): mutate methodresponses added by integrations #26718

Closed
wants to merge 1 commit into from

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Aug 11, 2023

The StepFunctionsIntegration integration can produce 200, 400 or 500 status codes.

To make its usage more convenient, it also adds default methodResponses for each of those statuses; if it didn't do this, the user would have to define the 3 method responses every time it uses the integration. However, the problem comes if the user wants to modify the default method responses. This is currently not possible, as addMethodResponse will just add to the array, adding multiple entries for the same statusCode, of which CloudFormation will deploy one nondeterministically and the rest is lost.


This PR address this problem by extending the feature set of addMethodResponse. It shouldn't currently be called multiple times for the same status code. We add that feature, and define that it merges the new method response fields with any existing method responses that share the same status code.

This makes it trivial to do things like add headers to existing responses.

Sister PR to #26720.

Relates to #26586 and #26636.


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

The `StepFunctionsIntegration` adds methodResponses for status codes
`200`, `400` and `500`. Because `addMethodResponse()` only ever adds
to the method response array, this makes it impossible for a user
to modify any of the responses added by the integration (for example,
to add headers).
@aws-cdk-automation aws-cdk-automation requested a review from a team August 11, 2023 11:27
@github-actions github-actions bot added the p2 label Aug 11, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 11, 2023
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.

rix0rrr added a commit to lpizzinidev/aws-cdk that referenced this pull request Aug 11, 2023
@rix0rrr rix0rrr force-pushed the huijbers/merge-methodresponse branch 2 times, most recently from 2ca7776 to bf6dc66 Compare August 11, 2023 12:13
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Aug 11, 2023
@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Aug 23, 2023

No one seems to need this change. Closing until we get interest on it.

@rix0rrr rix0rrr closed this Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2 pr/do-not-merge This PR should not be merged at this time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants