Skip to content

CEXT-5293: Separating region options by environment - #35

Merged
pdohogne-magento merged 2 commits into
mainfrom
CEXT-5293-stage-region
Oct 6, 2025
Merged

CEXT-5293: Separating region options by environment#35
pdohogne-magento merged 2 commits into
mainfrom
CEXT-5293-stage-region

Conversation

@pdohogne-magento

@pdohogne-magento pdohogne-magento commented Oct 1, 2025

Copy link
Copy Markdown
Collaborator

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 amer and amer2, prod will support amer, emea, and apac

How Has This Been Tested?

Unit tests, manual testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Comment thread lib/constants.js
Comment on lines 28 to 32
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'
}

@bhairavi25 bhairavi25 Oct 2, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's my next ticket (CEXT-5236)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant PR: #36

@nofuss nofuss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good enough

Comment thread lib/DbBase.js Outdated
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()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use AIO_DB_ENVIRONMENT

Comment thread lib/DbBase.js
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)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdohogne-magento
pdohogne-magento merged commit ab0b52d into main Oct 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants