CEXT-5293: Separating region options by environment - #35
Conversation
| const ENDPOINTS = { | ||
| // TODO: Replace with actual endpoints | ||
| [PROD_ENV]: 'https://db.<region>.adobe.io', | ||
| [STAGE_ENV]: 'https://db-stage.<region>.adobe.io' | ||
| [STAGE_ENV]: 'https://storage-database-<region>.stg.app-builder.adp.adobe.io' | ||
| } |
There was a problem hiding this comment.
internal endpoints should be used if the lib is invoked in the context of Adobe Runtime and use public endpoints for all other cases. Below are examples of how aio-lib-state handles this:
https://github.com/adobe/aio-lib-state/blob/main/lib/constants.js#L39-L42
https://github.com/adobe/aio-lib-state/blob/main/lib/constants.js#L18-L23
https://github.com/adobe/aio-lib-state/blob/main/lib/constants.js#L39-L42
Here are our internal endpoints:
amer - https://storage-database-amer.stg.app-builder.int.adp.adobe.io
amer2 - https://storage-database-amer2.stg.app-builder.int.adp.adobe.io
There was a problem hiding this comment.
Yep, that's my next ticket (CEXT-5236)
| this.region = region.toLowerCase() | ||
| if (!ALLOWED_REGIONS.includes(this.region)) { | ||
| throw new DbError(`Invalid region '${region}', must be one of: ${ALLOWED_REGIONS.join(', ')}`) | ||
| const env = getCliEnv() |
There was a problem hiding this comment.
This looked odd to me because aio-lib-db is not always used in a CLI context, but that's how it's done in aio-lib-state... so much for naming conventions
There was a problem hiding this comment.
Agreed, though I do think it's not a bad idea to also check for a more appropriately-named environment variable first. Just because lib-state does it this way doesn't mean we can't do better 😃.
getCliEnv() is from the (poorly named) aio-lib-env library and only checks the AIO_CLI_ENV environment variable and cli.env AIO config value. I'm not a big fan of having AIO_CLI_ENV as a required environment variable in a non-CLI context. In the API repo we check the ADOBE_ENVIRONMENT variable, I think we can also use that here.
There was a problem hiding this comment.
Updated to use AIO_DB_ENVIRONMENT
| throw new DbError(`Invalid region '${region}', must be one of: ${ALLOWED_REGIONS.join(', ')}`) | ||
| const env = getCliEnv() | ||
| const validRegions = ALLOWED_REGIONS[env] | ||
| if (!validRegions.includes(this.region)) { |
There was a problem hiding this comment.
thank you for NOT using schema validation like in aio-lib-state: https://github.com/adobe/aio-lib-state/blob/56ec324323603eb497d71e6edc86bca448a58d51/lib/AdobeState.js#L247
Description
Separate available region options for stage and prod environments
See also:
Related Issue
CEXT-5293: Normalize ABDB service urls in Stage
Motivation and Context
Stage only supports
amerandamer2, prod will supportamer,emea, andapacHow Has This Been Tested?
Unit tests, manual testing
Screenshots (if appropriate):
Types of changes
Checklist: