-
Notifications
You must be signed in to change notification settings - Fork 603
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
SDK throws "Region is missing" error even if region is defined in config #3469
Comments
This happens because
|
The aws-sdk-js-v3/packages/node-config-provider/src/configLoader.ts Lines 27 to 37 in ec43acf
|
Proposed fix: read profile from configuration and pass it to loadNodeConfig call. Example diff in client-dynamodb for region configuration: $ git diff
diff --git a/clients/client-dynamodb/src/DynamoDBClient.ts b/clients/client-dynamodb/src/DynamoDBClient.ts
index a3241382b9..30196d4e2b 100644
--- a/clients/client-dynamodb/src/DynamoDBClient.ts
+++ b/clients/client-dynamodb/src/DynamoDBClient.ts
@@ -399,6 +399,11 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
* The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK.
*/
defaultsMode?: DefaultsMode | Provider<DefaultsMode>;
+
+ /**
+ * Name of the AWS CLI profile to use.
+ */
+ profile: string | undefined;
}
type DynamoDBClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
diff --git a/clients/client-dynamodb/src/runtimeConfig.ts b/clients/client-dynamodb/src/runtimeConfig.ts
index bd9889770e..fb2795e60b 100644
--- a/clients/client-dynamodb/src/runtimeConfig.ts
+++ b/clients/client-dynamodb/src/runtimeConfig.ts
@@ -31,6 +31,7 @@ import { resolveDefaultsModeConfig } from "@aws-sdk/util-defaults-mode-node";
* @internal
*/
export const getRuntimeConfig = (config: DynamoDBClientConfig) => {
+ const { profile } = config;
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
@@ -50,7 +51,8 @@ export const getRuntimeConfig = (config: DynamoDBClientConfig) => {
endpointDiscoveryEnabledProvider:
config?.endpointDiscoveryEnabledProvider ?? loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS),
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
- region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
+ region:
+ config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, { profile, ...NODE_REGION_CONFIG_FILE_OPTIONS }),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
retryMode:
config?.retryMode ?? |
Adding In v2 region resolution, region is only resolved from the default profile or the |
Closing this issue as:
If you want to set profile, use environment variable |
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. |
Describe the bug
SDK throws "Region is missing" error even if region is defined in config
Your environment
SDK version number
@aws-sdk/client-dynamodb@3.55.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
v16.14.0
Steps to reproduce
Configure AWS profile as follows, and verify that region is set in AWS Config
Test code to run:
Observed behavior
Expected behavior
Prints
us-west-2
The text was updated successfully, but these errors were encountered: