Fix api_gateway_authorizer caching ttl in case explicitly set to 0 #8267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Community Note
Fixes #705
Changes proposed in this pull request:
The GetOk will compare the value to the default zero value of a type. When the ttl is set to 0, the value matches the default zero value of the type Integer and will be ignored for the api request.
Normally not a problem, but in this case, this results in an authorizer with a cache ttl of null, which defaults to 300s on AWS side. This is also not visible properly in the AWS console, since the value is displayed as "undefined" and the checkbox for caching is not activated. So it looks like the caching is disabled, but the default caching ttl of 300s kicks in and produces unreliable results in the API Gateway behaviour.
So this change uses the GetOkExists function for the parameter validation which will not compare
the value to the type zero value and therefore the resource will now accept an explicitly value of 0 for
the parameter authorizer_result_ttl_in_seconds.