aws-apigateway: GatewayResponse needs replacement when rest api gets redeployed #28652
Labels
@aws-cdk/aws-apigateway
Related to Amazon API Gateway
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
Describe the bug
Whenever the deployment updates occur for RestApi, the existing GatewayResponse resources are not added back to the API's gateway responses post new deployment, thus triggering responses with the default response template (
{"message":$context.error.messageString}
) instead of the custom ones.Expected Behavior
Responses need to be from custom response template defined via the unchanged GatewayResponse CDK resources.
Current Behavior
Getting responses with the default response template (
{"message":$context.error.messageString}
) instead in spite of GatewayResponse resources in CDK referring to the right RestApi.Reproduction Steps
Possible Solution
Potential Cause
RestApi Deployment depend on GatewayResponse resources but not the other way around. However adding RestApi Deployment on the GatewayResponse's "Depends On" list would cause circular dependency. Could this be the cause?
Does this mean it is expected to replace GatewayResponse resources (via salting the id field) whenever rest api gets redeployed? Or is there other means to solve this problem?
Workaround
Additional Information/Context
With the workaround above, due to salting the id with timestamp, the GatewayResponse resources get replaced (destroyed & recreated) for every
cdk deploy
(regardless of changes to the custom response props).However, since the logicalId for Deployment doesn't include GatewayResponse ID, the workaround would not trigger a deployment. (ref: https://github.com/aws/aws-cdk/pull/11068/files/619d94cd0b49ea1eefe3617949975cecb33f7ffa)
So I would like to know if there is a way to avoid the unintended CDK resource replacements.
CDK CLI Version
2.118.0 (build a40f2ec)
Framework Version
No response
Node.js Version
v16.11.1
OS
Linux
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: