Skip to content

Commit 1b901b2

Browse files
committed
feat(clients): profile setting for clients
feat(rds-signer): profile awareness for rds and dsql signers feat(clients): profile scoped clients
1 parent ead4f4e commit 1b901b2

File tree

29 files changed

+577
-100
lines changed

29 files changed

+577
-100
lines changed

clients/client-cognito-identity/src/CognitoIdentityClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
267267
*/
268268
region?: string | __Provider<string>;
269269

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

clients/client-cognito-identity/src/runtimeConfig.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getRuntimeConfig = (config: CognitoIdentityClientConfig) => {
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: CognitoIdentityClientConfig) => {
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-s3/src/S3Client.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
658658
*/
659659
region?: string | __Provider<string>;
660660

661+
/**
662+
* Setting a client profile is similar to setting a value for the
663+
* AWS_PROFILE environment variable. Setting a profile on a client
664+
* in code only affects the single client instance, unlike AWS_PROFILE.
665+
*
666+
* When set, and only for environments where an AWS configuration
667+
* file exists, fields configurable by this file will be retrieved
668+
* from the specified profile within that file.
669+
* Conflicting code configuration and environment variables will
670+
* still have higher priority.
671+
*
672+
* For client credential resolution that involves checking the AWS
673+
* configuration file, the client's profile (this value) will be
674+
* used unless a different profile is set in the credential
675+
* provider options.
676+
*
677+
*/
678+
profile?: string;
679+
661680
/**
662681
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
663682
* @internal

clients/client-s3/src/models/models_0.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// smithy-typescript generated code
22
import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client";
3-
43
import { StreamingBlobTypes } from "@smithy/types";
54

65
import { S3ServiceException as __BaseException } from "./S3ServiceException";

clients/client-s3/src/models/models_1.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// smithy-typescript generated code
22
import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client";
3-
43
import { StreamingBlobTypes } from "@smithy/types";
54

65
import {
@@ -40,7 +39,6 @@ import {
4039
Tag,
4140
TransitionDefaultMinimumObjectSize,
4241
} from "./models_0";
43-
4442
import { S3ServiceException as __BaseException } from "./S3ServiceException";
4543

4644
/**

clients/client-s3/src/runtimeConfig.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const getRuntimeConfig = (config: S3ClientConfig) => {
4141
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
4242
const clientSharedValues = getSharedRuntimeConfig(config);
4343
awsCheckVersion(process.version);
44+
const profileConfig = { profile: config?.profile };
4445
return {
4546
...clientSharedValues,
4647
...config,
@@ -52,30 +53,39 @@ export const getRuntimeConfig = (config: S3ClientConfig) => {
5253
config?.defaultUserAgentProvider ??
5354
createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
5455
disableS3ExpressSessionAuth:
55-
config?.disableS3ExpressSessionAuth ?? loadNodeConfig(NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS),
56+
config?.disableS3ExpressSessionAuth ??
57+
loadNodeConfig(NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS, profileConfig),
5658
eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider,
57-
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
59+
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
5860
md5: config?.md5 ?? Hash.bind(null, "md5"),
59-
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
61+
region:
62+
config?.region ??
63+
loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...profileConfig }),
6064
requestChecksumCalculation:
61-
config?.requestChecksumCalculation ?? loadNodeConfig(NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS),
65+
config?.requestChecksumCalculation ??
66+
loadNodeConfig(NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS, profileConfig),
6267
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6368
responseChecksumValidation:
64-
config?.responseChecksumValidation ?? loadNodeConfig(NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS),
69+
config?.responseChecksumValidation ??
70+
loadNodeConfig(NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS, profileConfig),
6571
retryMode:
6672
config?.retryMode ??
67-
loadNodeConfig({
68-
...NODE_RETRY_MODE_CONFIG_OPTIONS,
69-
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
70-
}),
73+
loadNodeConfig(
74+
{
75+
...NODE_RETRY_MODE_CONFIG_OPTIONS,
76+
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
77+
},
78+
config
79+
),
7180
sha1: config?.sha1 ?? Hash.bind(null, "sha1"),
7281
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
73-
sigv4aSigningRegionSet: config?.sigv4aSigningRegionSet ?? loadNodeConfig(NODE_SIGV4A_CONFIG_OPTIONS),
82+
sigv4aSigningRegionSet: config?.sigv4aSigningRegionSet ?? loadNodeConfig(NODE_SIGV4A_CONFIG_OPTIONS, profileConfig),
7483
streamCollector: config?.streamCollector ?? streamCollector,
7584
streamHasher: config?.streamHasher ?? streamHasher,
76-
useArnRegion: config?.useArnRegion ?? loadNodeConfig(NODE_USE_ARN_REGION_CONFIG_OPTIONS),
77-
useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),
78-
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS),
79-
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS),
85+
useArnRegion: config?.useArnRegion ?? loadNodeConfig(NODE_USE_ARN_REGION_CONFIG_OPTIONS, profileConfig),
86+
useDualstackEndpoint:
87+
config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, profileConfig),
88+
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, profileConfig),
89+
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig),
8090
};
8191
};

clients/client-sts/src/STSClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
198198
*/
199199
region?: string | __Provider<string>;
200200

201+
/**
202+
* Setting a client profile is similar to setting a value for the
203+
* AWS_PROFILE environment variable. Setting a profile on a client
204+
* in code only affects the single client instance, unlike AWS_PROFILE.
205+
*
206+
* When set, and only for environments where an AWS configuration
207+
* file exists, fields configurable by this file will be retrieved
208+
* from the specified profile within that file.
209+
* Conflicting code configuration and environment variables will
210+
* still have higher priority.
211+
*
212+
* For client credential resolution that involves checking the AWS
213+
* configuration file, the client's profile (this value) will be
214+
* used unless a different profile is set in the credential
215+
* provider options.
216+
*
217+
*/
218+
profile?: string;
219+
201220
/**
202221
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
203222
* @internal

clients/client-sts/src/runtimeConfig.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const getRuntimeConfig = (config: STSClientConfig) => {
3434
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
3535
const clientSharedValues = getSharedRuntimeConfig(config);
3636
awsCheckVersion(process.version);
37+
const profileConfig = { profile: config?.profile };
3738
return {
3839
...clientSharedValues,
3940
...config,
@@ -59,19 +60,25 @@ export const getRuntimeConfig = (config: STSClientConfig) => {
5960
signer: new NoAuthSigner(),
6061
},
6162
],
62-
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
63-
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
63+
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
64+
region:
65+
config?.region ??
66+
loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...profileConfig }),
6467
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
6568
retryMode:
6669
config?.retryMode ??
67-
loadNodeConfig({
68-
...NODE_RETRY_MODE_CONFIG_OPTIONS,
69-
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
70-
}),
70+
loadNodeConfig(
71+
{
72+
...NODE_RETRY_MODE_CONFIG_OPTIONS,
73+
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
74+
},
75+
config
76+
),
7177
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
7278
streamCollector: config?.streamCollector ?? streamCollector,
73-
useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),
74-
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS),
75-
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS),
79+
useDualstackEndpoint:
80+
config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, profileConfig),
81+
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, profileConfig),
82+
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig),
7683
};
7784
};

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAccountIdEndpointModeRuntimeConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
8989
null, AwsDependency.AWS_SDK_CORE,
9090
"/account-id-endpoint");
9191
writer.write(
92-
"loadNodeConfig(NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS)");
92+
"loadNodeConfig(NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS, profileConfig)");
9393
});
9494
break;
9595
default:

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfig.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,26 @@ public void addConfigInterfaceFields(
9999
? "The AWS region to which this client will send requests"
100100
: "The AWS region to use as signing region for AWS Auth")
101101
.write("region?: string | __Provider<string>;\n");
102+
103+
104+
writer.writeDocs(
105+
"""
106+
Setting a client profile is similar to setting a value for the
107+
AWS_PROFILE environment variable. Setting a profile on a client
108+
in code only affects the single client instance, unlike AWS_PROFILE.
109+
110+
When set, and only for environments where an AWS configuration
111+
file exists, fields configurable by this file will be retrieved
112+
from the specified profile within that file.
113+
Conflicting code configuration and environment variables will
114+
still have higher priority.
115+
116+
For client credential resolution that involves checking the AWS
117+
configuration file, the client's profile (this value) will be
118+
used unless a different profile is set in the credential
119+
provider options.
120+
""")
121+
.write("profile?: string;\n");
102122
}
103123
}
104124

@@ -145,6 +165,7 @@ public void prepareCustomizations(
145165
writer.addDependency(AwsDependency.AWS_SDK_CORE);
146166
writer.addImport("emitWarningIfUnsupportedVersion", "awsCheckVersion", AwsDependency.AWS_SDK_CORE);
147167
writer.write("awsCheckVersion(process.version);");
168+
writer.write("const profileConfig = { profile: config?.profile };");
148169
}
149170
}
150171

@@ -173,7 +194,7 @@ private Map<String, Consumer<TypeScriptWriter>> getDefaultConfig(
173194
writer.addImport("NODE_REGION_CONFIG_FILE_OPTIONS", "NODE_REGION_CONFIG_FILE_OPTIONS",
174195
TypeScriptDependency.CONFIG_RESOLVER);
175196
writer.write(
176-
"loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS)");
197+
"loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, {...NODE_REGION_CONFIG_FILE_OPTIONS, ...profileConfig})");
177198
});
178199
default:
179200
return Collections.emptyMap();
@@ -216,7 +237,7 @@ private Map<String, Consumer<TypeScriptWriter>> getEndpointConfigWriters(
216237
writer.addImport("NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS",
217238
"NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS",
218239
TypeScriptDependency.CONFIG_RESOLVER);
219-
writer.write("loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS)");
240+
writer.write("loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, profileConfig)");
220241
},
221242
"useFipsEndpoint", writer -> {
222243
writer.addDependency(TypeScriptDependency.NODE_CONFIG_PROVIDER);
@@ -226,7 +247,7 @@ private Map<String, Consumer<TypeScriptWriter>> getEndpointConfigWriters(
226247
writer.addImport("NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS",
227248
"NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS",
228249
TypeScriptDependency.CONFIG_RESOLVER);
229-
writer.write("loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)");
250+
writer.write("loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, profileConfig)");
230251
}
231252
);
232253
default:

0 commit comments

Comments
 (0)