Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add AccountIdEndpointMode config option #6036

Merged
merged 19 commits into from
Jul 24, 2024

Conversation

siddsriv
Copy link
Contributor

@siddsriv siddsriv commented Apr 30, 2024

Issue

Internal JS-4633
Part 3

Description

Adds support for AccountIdEndpointMode config option. (client config, env, config file)

Testing

  • Unit tests
  • Generate the option in ClientInputEndpointParameters
    example:
export interface ClientInputEndpointParameters {
  region?: string | Provider<string>;
  useDualstackEndpoint?: boolean | Provider<boolean>;
  useFipsEndpoint?: boolean | Provider<boolean>;
  endpoint?: string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
  accountId?: string | Provider<string>;
  accountIdEndpointMode?: string | Provider<string>;
}

(this is before the merging of #6035 which is why accountId is generated as well)

  • Generate the option in runtimeConfig.ts
    example:
export const getRuntimeConfig = (config: DynamoDBClientConfig) => {
 .
 .
  return {
    ...clientSharedValues,
    ...config,
    runtime: "node",
    defaultsMode,
    accountIdEndpointMode:
      config?.accountIdEndpointMode ?? loadNodeConfig(NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS),
    bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
  • import should come from @aws-sdk/core/account-id-endpoint instead of just @aws-sdk/core
    Example:
import { emitWarningIfUnsupportedVersion as awsCheckVersion } from "@aws-sdk/core";
import { NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS } from "@aws-sdk/core/account-id-endpoint";
import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node";
import { NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS } from "@aws-sdk/middleware-endpoint-discovery";
  • Generate the option in runtimeConfig.browser.ts
    example:
export const getRuntimeConfig = (config: DynamoDBClientConfig) => {
  .
  .
  return {
    ...clientSharedValues,
    ...config,
    runtime: "browser",
    defaultsMode,
    accountIdEndpointMode: config?.accountIdEndpointMode ?? (() => Promise.resolve(DEFAULT_ACCOUNT_ID_ENDPOINT_MODE)),
    bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
  • Unit tests for the config option and resolution
yarn run v1.22.21
$ jest
.
.
 PASS  src/submodules/account-id-endpoint/AccountIdEndpointModeConstants.spec.ts (7.051 s)
 PASS  src/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.spec.ts (7.089 s)
.
.

Checklist

  • refactor for core/submodules
  • If adding new public functions, did you add the @public tag and enable doc generation on the package?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@siddsriv siddsriv requested a review from a team as a code owner April 30, 2024 05:01
@siddsriv siddsriv marked this pull request as draft April 30, 2024 05:01
@siddsriv siddsriv changed the title feat(core): add AccountIdEndpointMode config feat(core): add AccountIdEndpointMode config option Apr 30, 2024
@siddsriv siddsriv marked this pull request as ready for review June 18, 2024 17:45
@siddsriv
Copy link
Contributor Author

siddsriv commented Jun 21, 2024

possibly requires a careful look: exporting from account-id-endpoints submodule especially for config options since they will be used during runtime. the exports for this dir in package.json look right to me, let me know if i missed anything -- all tests are working okay, though it's a little tough to fully test the new client config option's functioning during runtime. i manually confirmed that everything is being imported correctly and the loading statements are correct in the generated client.

[EDIT]: added a TODO to use addImportSubmodule in our codegen for adding dependency on core/account-id-endpoint when it's available. relying on adding a string based import for that as of now.

@siddsriv siddsriv merged commit 1cb4edc into aws:main Jul 24, 2024
5 checks passed
@siddsriv siddsriv deleted the accId-config branch July 24, 2024 16:11
Copy link

github-actions bot commented Aug 8, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants