Skip to content

Commit 7c66035

Browse files
committed
feat(clients): make profile config unconditional in aws codegen
1 parent 32e7b72 commit 7c66035

File tree

8 files changed

+49
-4
lines changed

8 files changed

+49
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ 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+
}
102103

103-
104-
writer.writeDocs(
104+
writer.writeDocs(
105105
"""
106106
Setting a client profile is similar to setting a value for the
107107
AWS_PROFILE environment variable. Setting a profile on a client
@@ -119,7 +119,6 @@ public void addConfigInterfaceFields(
119119
provider options.
120120
""")
121121
.write("profile?: string;\n");
122-
}
123122
}
124123

125124
@Override
@@ -165,6 +164,8 @@ public void prepareCustomizations(
165164
writer.addDependency(AwsDependency.AWS_SDK_CORE);
166165
writer.addImport("emitWarningIfUnsupportedVersion", "awsCheckVersion", AwsDependency.AWS_SDK_CORE);
167166
writer.write("awsCheckVersion(process.version);");
167+
}
168+
if (target.equals(LanguageTarget.NODE)) {
168169
writer.write("const profileConfig = { profile: config?.profile };");
169170
}
170171
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
8484
writer.addDependency(AwsDependency.AWS_SDK_UTIL_USER_AGENT_NODE);
8585
writer.addImport("NODE_APP_ID_CONFIG_OPTIONS", "NODE_APP_ID_CONFIG_OPTIONS",
8686
AwsDependency.AWS_SDK_UTIL_USER_AGENT_NODE);
87-
writer.write("loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig)");
87+
writer.write(
88+
"loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig)"
89+
);
8890
}
8991
);
9092
case BROWSER:

private/aws-echo-service/src/EchoServiceClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
136136
*/
137137
disableHostPrefix?: boolean;
138138

139+
/**
140+
* Setting a client profile is similar to setting a value for the
141+
* AWS_PROFILE environment variable. Setting a profile on a client
142+
* in code only affects the single client instance, unlike AWS_PROFILE.
143+
*
144+
* When set, and only for environments where an AWS configuration
145+
* file exists, fields configurable by this file will be retrieved
146+
* from the specified profile within that file.
147+
* Conflicting code configuration and environment variables will
148+
* still have higher priority.
149+
*
150+
* For client credential resolution that involves checking the AWS
151+
* configuration file, the client's profile (this value) will be
152+
* used unless a different profile is set in the credential
153+
* provider options.
154+
*
155+
*/
156+
profile?: string;
157+
139158
/**
140159
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
141160
* @internal

private/aws-echo-service/src/runtimeConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const getRuntimeConfig = (config: EchoServiceClientConfig) => {
2323
const defaultsMode = resolveDefaultsModeConfig(config);
2424
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
2525
const clientSharedValues = getSharedRuntimeConfig(config);
26+
const profileConfig = { profile: config?.profile };
2627
return {
2728
...clientSharedValues,
2829
...config,

private/aws-protocoltests-smithy-rpcv2-cbor/src/RpcV2ProtocolClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
189189
*/
190190
disableHostPrefix?: boolean;
191191

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

private/aws-protocoltests-smithy-rpcv2-cbor/src/runtimeConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const getRuntimeConfig = (config: RpcV2ProtocolClientConfig) => {
2323
const defaultsMode = resolveDefaultsModeConfig(config);
2424
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
2525
const clientSharedValues = getSharedRuntimeConfig(config);
26+
const profileConfig = { profile: config?.profile };
2627
return {
2728
...clientSharedValues,
2829
...config,

private/weather-legacy-auth/src/runtimeConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const getRuntimeConfig = (config: WeatherClientConfig) => {
2525
const defaultsMode = resolveDefaultsModeConfig(config);
2626
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
2727
const clientSharedValues = getSharedRuntimeConfig(config);
28+
const profileConfig = { profile: config?.profile };
2829
return {
2930
...clientSharedValues,
3031
...config,

private/weather/src/runtimeConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const getRuntimeConfig = (config: WeatherClientConfig) => {
2525
const defaultsMode = resolveDefaultsModeConfig(config);
2626
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
2727
const clientSharedValues = getSharedRuntimeConfig(config);
28+
const profileConfig = { profile: config?.profile };
2829
return {
2930
...clientSharedValues,
3031
...config,

0 commit comments

Comments
 (0)