Skip to content

Commit afd9eea

Browse files
authored
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
};

clients/client-account/src/AccountClient.ts

+19
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
222222
*/
223223
region?: string | __Provider<string>;
224224

225+
/**
226+
* Setting a client profile is similar to setting a value for the
227+
* AWS_PROFILE environment variable. Setting a profile on a client
228+
* in code only affects the single client instance, unlike AWS_PROFILE.
229+
*
230+
* When set, and only for environments where an AWS configuration
231+
* file exists, fields configurable by this file will be retrieved
232+
* from the specified profile within that file.
233+
* Conflicting code configuration and environment variables will
234+
* still have higher priority.
235+
*
236+
* For client credential resolution that involves checking the AWS
237+
* configuration file, the client's profile (this value) will be
238+
* used unless a different profile is set in the credential
239+
* provider options.
240+
*
241+
*/
242+
profile?: string;
243+
225244
/**
226245
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
227246
* @internal

clients/client-account/src/runtimeConfig.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getRuntimeConfig = (config: AccountClientConfig) => {
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: AccountClientConfig) => {
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
};

clients/client-acm-pca/src/ACMPCAClient.ts

+19
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
273273
*/
274274
region?: string | __Provider<string>;
275275

276+
/**
277+
* Setting a client profile is similar to setting a value for the
278+
* AWS_PROFILE environment variable. Setting a profile on a client
279+
* in code only affects the single client instance, unlike AWS_PROFILE.
280+
*
281+
* When set, and only for environments where an AWS configuration
282+
* file exists, fields configurable by this file will be retrieved
283+
* from the specified profile within that file.
284+
* Conflicting code configuration and environment variables will
285+
* still have higher priority.
286+
*
287+
* For client credential resolution that involves checking the AWS
288+
* configuration file, the client's profile (this value) will be
289+
* used unless a different profile is set in the credential
290+
* provider options.
291+
*
292+
*/
293+
profile?: string;
294+
276295
/**
277296
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
278297
* @internal

clients/client-acm-pca/src/runtimeConfig.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getRuntimeConfig = (config: ACMPCAClientConfig) => {
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: ACMPCAClientConfig) => {
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
};

clients/client-acm/src/ACMClient.ts

+19
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
234234
*/
235235
region?: string | __Provider<string>;
236236

237+
/**
238+
* Setting a client profile is similar to setting a value for the
239+
* AWS_PROFILE environment variable. Setting a profile on a client
240+
* in code only affects the single client instance, unlike AWS_PROFILE.
241+
*
242+
* When set, and only for environments where an AWS configuration
243+
* file exists, fields configurable by this file will be retrieved
244+
* from the specified profile within that file.
245+
* Conflicting code configuration and environment variables will
246+
* still have higher priority.
247+
*
248+
* For client credential resolution that involves checking the AWS
249+
* configuration file, the client's profile (this value) will be
250+
* used unless a different profile is set in the credential
251+
* provider options.
252+
*
253+
*/
254+
profile?: string;
255+
237256
/**
238257
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
239258
* @internal

clients/client-acm/src/runtimeConfig.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getRuntimeConfig = (config: ACMClientConfig) => {
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: ACMClientConfig) => {
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
};

clients/client-amp/src/AmpClient.ts

+19
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
294294
*/
295295
region?: string | __Provider<string>;
296296

297+
/**
298+
* Setting a client profile is similar to setting a value for the
299+
* AWS_PROFILE environment variable. Setting a profile on a client
300+
* in code only affects the single client instance, unlike AWS_PROFILE.
301+
*
302+
* When set, and only for environments where an AWS configuration
303+
* file exists, fields configurable by this file will be retrieved
304+
* from the specified profile within that file.
305+
* Conflicting code configuration and environment variables will
306+
* still have higher priority.
307+
*
308+
* For client credential resolution that involves checking the AWS
309+
* configuration file, the client's profile (this value) will be
310+
* used unless a different profile is set in the credential
311+
* provider options.
312+
*
313+
*/
314+
profile?: string;
315+
297316
/**
298317
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
299318
* @internal

clients/client-amp/src/runtimeConfig.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getRuntimeConfig = (config: AmpClientConfig) => {
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: AmpClientConfig) => {
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
};

clients/client-amplify/src/AmplifyClient.ts

+19
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
306306
*/
307307
region?: string | __Provider<string>;
308308

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

0 commit comments

Comments
 (0)