Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(codegen): consistently add region as config option when generated client is Sigv4 but not AWS #6156

Merged
merged 6 commits into from
Jun 4, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Jun 3, 2024

Issue

N/A, internal code generation

Description

The goal is to set the region configuration and all related codegen on a consistent condition, i.e. the service being either AWS service or being a Sigv4 service. (Non-AWS sigv4 services exist).

Testing

Restored unit tests removed in #5497 (committed as 6c9f913 in #5543)

@kuhe kuhe requested a review from a team as a code owner June 3, 2024 18:25
: "The AWS region to use as signing region for AWS Auth")
.write("region?: string | __Provider<string>;\n");
}
if (isSigV4Service(settings, model) || isAwsService(settings, model)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed condition to AWS or SigV4

@@ -130,7 +128,7 @@ public List<ExtensionConfigurationInterface> getExtensionConfigurationInterfaces
Model model,
TypeScriptSettings settings
) {
if (isAwsService(settings, model)) {
if (isSigV4Service(settings, model) || isAwsService(settings, model)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed condition to AWS or SigV4 for consistency.

return MapUtils.of("region", writer -> {
writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY);
writer.addImport("invalidProvider", "invalidProvider",
if (isSigV4Service(settings, model) || isAwsService(settings, model)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed condition to AWS or SigV4 for consistency.

writer
.addImport("AwsCredentialIdentityProvider", null, TypeScriptDependency.SMITHY_TYPES)
.writeDocs("""
if (isSigV4Service(service) && !areAllOptionalAuthOperations(model, service)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition for adding AwsCredentialIdentityProvider is now only isSigV4 and not both isSigV4 and isAws.

Should this instead remain

isAwsService(service) && isSigV4Service(service)

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRuntimeConfigWriters seems to write credentialDefaultProvider only is isAwsService. So maybe that condition should remain here?

@@ -30,6 +31,7 @@ export const getRuntimeConfig = (config: CodeCatalystClientConfig) => {
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
Copy link
Contributor Author

@kuhe kuhe Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is okay to add to CodeCatalyst, because even now it throws an error on missing region (due to the config resolver and not the runtimeConfig default).

Comment on lines 98 to 101
if (!settings.getExperimentalIdentityAndAuth()) {
// This additional ID&A check is applied because
// the AwsSdkCustomizeSigV4Auth class also adds region
// under these conditions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we want to write region independent of experimentalIdentityAndAuth (when isSigV4Service or isAwsService). With the documentation changing if it isAwsService (client will send requests) v/s just isSigV4Service (signing region). So it seems we can just do this from one place without looking at experimentalIdentityAndAuth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving this to one location then

writer
.addImport("AwsCredentialIdentityProvider", null, TypeScriptDependency.SMITHY_TYPES)
.writeDocs("""
if (isSigV4Service(service) && !areAllOptionalAuthOperations(model, service)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRuntimeConfigWriters seems to write credentialDefaultProvider only is isAwsService. So maybe that condition should remain here?

@kuhe kuhe merged commit 06f51cc into aws:main Jun 4, 2024
5 checks passed
@kuhe kuhe deleted the fix/codegen branch June 4, 2024 17:28
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants