Skip to content

Commit

Permalink
feat(clients): make profile config unconditional in aws codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Dec 16, 2024
1 parent 92bea2e commit 8bee88d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public void addConfigInterfaceFields(
? "The AWS region to which this client will send requests"
: "The AWS region to use as signing region for AWS Auth")
.write("region?: string | __Provider<string>;\n");
}


writer.writeDocs(
writer.writeDocs(
"""
Setting a client profile is similar to setting a value for the
AWS_PROFILE environment variable. Setting a profile on a client
Expand All @@ -119,7 +119,6 @@ public void addConfigInterfaceFields(
provider options.
""")
.write("profile?: string;\n");
}
}

@Override
Expand Down Expand Up @@ -165,6 +164,8 @@ public void prepareCustomizations(
writer.addDependency(AwsDependency.AWS_SDK_CORE);
writer.addImport("emitWarningIfUnsupportedVersion", "awsCheckVersion", AwsDependency.AWS_SDK_CORE);
writer.write("awsCheckVersion(process.version);");
}
if (target.equals(LanguageTarget.NODE)) {
writer.write("const profileConfig = { profile: config?.profile };");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
writer.addDependency(AwsDependency.AWS_SDK_UTIL_USER_AGENT_NODE);
writer.addImport("NODE_APP_ID_CONFIG_OPTIONS", "NODE_APP_ID_CONFIG_OPTIONS",
AwsDependency.AWS_SDK_UTIL_USER_AGENT_NODE);
writer.write("loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig)");
writer.write(
"loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, profileConfig)"
);
}
);
case BROWSER:
Expand Down
19 changes: 19 additions & 0 deletions private/aws-echo-service/src/EchoServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
*/
disableHostPrefix?: boolean;

/**
* Setting a client profile is similar to setting a value for the
* AWS_PROFILE environment variable. Setting a profile on a client
* in code only affects the single client instance, unlike AWS_PROFILE.
*
* When set, and only for environments where an AWS configuration
* file exists, fields configurable by this file will be retrieved
* from the specified profile within that file.
* Conflicting code configuration and environment variables will
* still have higher priority.
*
* For client credential resolution that involves checking the AWS
* configuration file, the client's profile (this value) will be
* used unless a different profile is set in the credential
* provider options.
*
*/
profile?: string;

/**
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
* @internal
Expand Down
1 change: 1 addition & 0 deletions private/aws-echo-service/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const getRuntimeConfig = (config: EchoServiceClientConfig) => {
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
const profileConfig = { profile: config?.profile };
return {
...clientSharedValues,
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
*/
disableHostPrefix?: boolean;

/**
* Setting a client profile is similar to setting a value for the
* AWS_PROFILE environment variable. Setting a profile on a client
* in code only affects the single client instance, unlike AWS_PROFILE.
*
* When set, and only for environments where an AWS configuration
* file exists, fields configurable by this file will be retrieved
* from the specified profile within that file.
* Conflicting code configuration and environment variables will
* still have higher priority.
*
* For client credential resolution that involves checking the AWS
* configuration file, the client's profile (this value) will be
* used unless a different profile is set in the credential
* provider options.
*
*/
profile?: string;

/**
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const getRuntimeConfig = (config: RpcV2ProtocolClientConfig) => {
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
const profileConfig = { profile: config?.profile };
return {
...clientSharedValues,
...config,
Expand Down
1 change: 1 addition & 0 deletions private/weather-legacy-auth/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const getRuntimeConfig = (config: WeatherClientConfig) => {
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
const profileConfig = { profile: config?.profile };
return {
...clientSharedValues,
...config,
Expand Down
1 change: 1 addition & 0 deletions private/weather/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const getRuntimeConfig = (config: WeatherClientConfig) => {
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
const profileConfig = { profile: config?.profile };
return {
...clientSharedValues,
...config,
Expand Down

0 comments on commit 8bee88d

Please sign in to comment.