-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(region_config): fix configure endpoint bug in getRegionPrefix (#129)
## Summary This PR fixes a bug inside `generateRegionPrefix` that caused some service endpoint in specific region is not getting configured correctly. https://github.com/Kong/lua-resty-aws/blob/50d9f0849eb03d4c2a3d7cc8a8cd10344a14df12/src/resty/aws/init.lua#L138-L149 This code originates from the [JS code here](https://github.com/aws/aws-sdk-js/blob/c0ec9d31057748cda57eac863273f5ef5a695782/lib/region_config.js#L4-L9): ``` function generateRegionPrefix(region) { if (!region) return null; var parts = region.split('-'); if (parts.length < 3) return null; return parts.slice(0, parts.length - 2).join('-') + '-*'; } ``` There is a bug in our Lua code, that `parts.slice(0, parts.length - 2).join('-') + '-*'` is fetching the `[0, #parts-2)` items from the region parts and concatenating with another asterisk. But our SDK is just replacing the last item in the array with an asterisk, which equals fetching `[0, #parts-2]` and concatenating with another asterisk. (Here I'm using an index starting with 0 to clarify the difference). This caused different results when we generated region prefixes: a region `cn-north-1` will result in `cn-*` in the JS function and `cn-north-*` in the Lua function. The PR fixes it and lets the `region_config_data` apply correctly. ## Issue FTI-6159 mentioned an issue caused by this bug, which happens inside `cn-north-1` that is expected to apply the `cn-*/*` endpoint config. The bug caused a mismatch and endpoint config cannot be applied correctly. This bug would also influence other regions like `us-isob-east-1`
- Loading branch information
Showing
2 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters