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

Adds accountId endpoint mode #4984

Merged

Conversation

cenedhryn
Copy link
Contributor

@cenedhryn cenedhryn commented Feb 29, 2024

Motivation and Context

Account Id endpoint routing has been unblocked by DDB being enabled for SRA identity and auth, thereby resolving credentials before endpoints. Some code changes are required to support this change, because the original code for account Id was written before SRA.

In addition, it adds AccountId Endpoint Mode as a built-in endpoint parameter. AccountIdMode should be configurable in profile file, system settings/env vars and at the client level

Modifications

  • Adds AccountIdMode as a built-in endpoint parameter
  • Adds codegen infrastructure for generating setter method on the client for accountIdMode
    • Introduces a simple class to represent a parameter, LocalParameter
    • Introduces a holder class for codegen for endpoint parameters that should be exposed on clients. Calling it EndpointParamsKnowledgeIndex, but for now accountIdMode is the only example.
  • Removes non-generic endpoint parameters from AwsEndpointProviderUtils, because this class is copied to all services. Instead, EndpointResolverInterceptorSpec.java generates logic for those parameters inside the provider itself (accountId, accountIdEndpointMode, s3GlobalEndpoint).
  • AccountIdMode is resolved in the BaseClientBuilder of each service by checking if the value is set on the client, otherwise it will call the resolver to see if any values are set through system properties or profile file

@cenedhryn cenedhryn requested a review from a team as a code owner February 29, 2024 19:48
Copy link

@cenedhryn cenedhryn changed the title Salande/account id mode Adds accountId endpoint mode Feb 29, 2024
package software.amazon.awssdk.codegen.model.internal;

/**
* Represents a generic parameter that can be code generated, but isn't tied to a specific model type
Copy link
Contributor

Choose a reason for hiding this comment

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

What does model type refer to here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A model shape that can be a parameter, such as a context parameter. Our existing codegen types are tightly coupled to the model, which didn't work for account id routing mode. Any suggestions for updating the description?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "model shape" as you describe sounds better

new LocalParameter("accountIdEndpointMode",
AccountIdEndpointMode.class,
"Sets the behavior when account ID based endpoints are created. "
+ "See {@link AccountIdEndpointMode} for values"));
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: when referencing classes in a javadoc, we should still use $T placeholder in case the class is not already imported by something else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the reminder, will fix!

Comment on lines 69 to 70
* The AWS account ID associated with the identity resolved for this request.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this accurate? The attribute name is "mode" but this says account ID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh... that could be a typo. Will update

builder.addStatement("$T identity = $T.joinLikeSync(selectedAuthScheme.identity())", TypeVariableName.get("T"),
CompletableFutureUtils.class);
builder.addStatement("$T accountId = null", String.class);
builder.beginControlFlow("if (identity instanceof $T)", AwsCredentialsIdentity.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, will AwsCredentialsIdentity be the only identity type that supports account ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd have to look in the crystal ball for that one. Nothing in the pipelines as for now, but it would be good to have another round of discussions here. It's a dilemma to build at the right level - neither adding support that's super generic and never diversified nor being too specific and then getting a broader use case is great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we have to add accountId in the future, we can support it through an interface.

Comment on lines 26 to 28
PREFERRED,
DISABLED,
REQUIRED;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get javadocs for each value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@cenedhryn cenedhryn merged commit 091fb43 into feature/master/accountid-endpoint-routing Mar 8, 2024
3 of 16 checks passed
@cenedhryn cenedhryn deleted the salande/account-id-mode branch March 8, 2024 00:08
cenedhryn added a commit that referenced this pull request Apr 18, 2024
* Add accountId endpoint mode enum, system properties, profile property
and resolver to aws core

* Supports resolving accountId and accountId endpoint mode parameters

* Testing accountId and accountId endpoint mode resolution logic

* Adds latest rules to accountId custom branch

* Sets up SRA auth for DynamoDb in custom branch (not yet active in public)

* Adds a temporary functional test for accountId to DynamoDb module

* fixing merge conflicts

* Minor fixes
cenedhryn added a commit that referenced this pull request Apr 22, 2024
…5119)

* Adds account ID as a built-in endpoint parameter (#4016)

* Refactors credential identity with separate implementing classes (#4024) (#4028)

* Adds accountId as a parameter to AWS credentials identity (#4029)

* Adds accountId to STS credentials providers (#4040)

* Adding accountId support to environment variable credential provider (#4327)

* Adds accountId support to process credentials provider (#4332)

* Adds account ID support for profile credentials provider sources (#4340)

* Adds accountId endpoint mode (#4984)

* Adding back existing endpoint files (#5120)

* changelog (#5121)
akidambisrinivasan pushed a commit to akidambisrinivasan/aws-sdk-java-v2 that referenced this pull request Jun 28, 2024
…ws#5119)

* Adds account ID as a built-in endpoint parameter (aws#4016)

* Refactors credential identity with separate implementing classes (aws#4024) (aws#4028)

* Adds accountId as a parameter to AWS credentials identity (aws#4029)

* Adds accountId to STS credentials providers (aws#4040)

* Adding accountId support to environment variable credential provider (aws#4327)

* Adds accountId support to process credentials provider (aws#4332)

* Adds account ID support for profile credentials provider sources (aws#4340)

* Adds accountId endpoint mode (aws#4984)

* Adding back existing endpoint files (aws#5120)

* changelog (aws#5121)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants