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

[apigateway]: Configured responseHeaders in apigateway.GatewayResponse doesn't support mapping #23105

Closed
grmorozov opened this issue Nov 27, 2022 · 7 comments
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug.

Comments

@grmorozov
Copy link

Describe the bug

GatewayResponse parameter mapping is broken after adding forced quotation of all parameters in this PR.

Previously, request parameters could be mapped to response parameters, for example headers.
That's it method.request.header.<name> should be a valid value for a response parameter. With forced quotation around parameter values, method.request.header.<name> becomes a string value and doesn't work.

Expected Behavior

CDK should not add extra quotes for GatewayResponse parameters. It should be possible to use request parameter values in response headers.

Current Behavior

CDK forces quotes around GatewayResponse parameter values. Mapping of request parameters in the response doesn't work.

Reproduction Steps

import * as apigateway from "aws-cdk-lib/aws-apigateway";
...
const api = new apigateway.RestApi(...);

api.addGatewayResponse(`gatewayResponse`, {
      type: apigateway.ResponseType.ACCESS_DENIED,
      responseHeaders: {
        'Access-Control-Allow-Origin': 'method.request.header.origin',
        'Access-Control-Allow-Credentials': "'true'",
        'Access-Control-Expose-Headers': "'x-amzn-errortype'",
      },
    })

Possible Solution

Reverting changes from this PR should solve the issue.

Additional Information/Context

No response

CDK CLI Version

2.48.0

Framework Version

No response

Node.js Version

v16.18.0

OS

macOS Monteray

Language

Typescript

Language Version

No response

Other information

The documentation about API Gateway responses doesn't clearly describe the use case of using request parameters in the response. More clear statement with an example can be found in OpenAPI documentation.

@grmorozov grmorozov added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 27, 2022
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Nov 27, 2022
@yuyokk
Copy link
Contributor

yuyokk commented Nov 27, 2022

Changes were reverted #23037

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@grmorozov
Copy link
Author

grmorozov commented Nov 28, 2022

23037 was merged 6 days ago. However with the latest version (2.52.0) I can still reproduce the issue.

@grmorozov grmorozov reopened this Nov 28, 2022
@peterwoodworth
Copy link
Contributor

The revert PR wasn't part of our 2.52.0 release, only one change made it through. The next version we release I would expect to have all the changes made since 2.51.0 launched. Feel free to ping me or reopen this if the bug is still present next release

@peterwoodworth peterwoodworth removed the needs-triage This issue or PR still needs to be triaged. label Nov 29, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@frikille
Copy link

@peterwoodworth Seems like with the latest release (v2.53.0) this is still not fixed: https://github.com/aws/aws-cdk/blob/v2.53.0/packages/@aws-cdk/aws-apigateway/lib/gateway-response.ts

@peterwoodworth
Copy link
Contributor

Yes, this release was also a special case where we only merged one specific fix. Our next standard release I should say... I would expect next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants