Skip to content

Commit afd9eea

Browse files
authoredDec 17, 2024··
feat(clients): profile setting for clients (#6728)
* feat(clients): profile setting for clients feat(rds-signer): profile awareness for rds and dsql signers feat(clients): profile scoped clients * feat(clients): codegen for client-scoped profiles * chore: formatting * test(aws-client-api-test): fix maximal config test * feat(clients): make profile config unconditional in aws codegen * test: fix unit tests * test(credential-provider-node): additional test case * chore(clients): update smithy-ts hash for passing profile to retry mode and max attempts
1 parent cae656f commit afd9eea

File tree

866 files changed

+15180
-3871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

866 files changed

+15180
-3871
lines changed
 

‎clients/client-accessanalyzer/src/AccessAnalyzerClient.ts

+19
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
309309
*/
310310
region?: string | __Provider<string>;
311311

312+
/**
313+
* Setting a client profile is similar to setting a value for the
314+
* AWS_PROFILE environment variable. Setting a profile on a client
315+
* in code only affects the single client instance, unlike AWS_PROFILE.
316+
*
317+
* When set, and only for environments where an AWS configuration
318+
* file exists, fields configurable by this file will be retrieved
319+
* from the specified profile within that file.
320+
* Conflicting code configuration and environment variables will
321+
* still have higher priority.
322+
*
323+
* For client credential resolution that involves checking the AWS
324+
* configuration file, the client's profile (this value) will be
325+
* used unless a different profile is set in the credential
326+
* provider options.
327+
*
328+
*/
329+
profile?: string;
330+
312331
/**
313332
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
314333
* @internal

‎clients/client-accessanalyzer/src/runtimeConfig.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => {
3232
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
3333
const clientSharedValues = getSharedRuntimeConfig(config);
3434
awsCheckVersion(process.version);
35+
const profileConfig = { profile: config?.profile };
3536
return {
3637
...clientSharedValues,
3738
...config,
@@ -42,19 +43,25 @@ export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => {
4243
defaultUserAgentProvider:
4344
config?.defaultUserAgentProvider ??
4445
createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
45-
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
46-
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
46+
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
47+
region:
48+
config?.region ??
49+
loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...profileConfig }),
4750
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
4851
retryMode:
4952
config?.retryMode ??
50-
loadNodeConfig({
51-
...NODE_RETRY_MODE_CONFIG_OPTIONS,
52-
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
53-
}),
53+
loadNodeConfig(
54+
{
55+
...NODE_RETRY_MODE_CONFIG_OPTIONS,
56+
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
57+
},
58+
config
59+
),
5460
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
5561
streamCollector: config?.streamCollector ?? streamCollector,
56-
useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),
57-
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS),
58-
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS),
62+
useDualstackEndpoint:
63+
config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, profileConfig),
64+
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, profileConfig),
65+
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig),
5966
};
6067
};

0 commit comments

Comments
 (0)
Please sign in to comment.