GODRIVER-3567 Add optional AWS SDK v2-based MONGODB-AWS authenticator submodule#2508
GODRIVER-3567 Add optional AWS SDK v2-based MONGODB-AWS authenticator submodule#2508qingyang-hu wants to merge 6 commits into
Conversation
|
There is an existing patch(es) for this commit SHA: Please note that the status that is posted is not in the context of this PR but rather the (latest) existing patch and that may affect some tests that may depend on the particular PR. If your tests do not rely on any PR-specific values (like base or head branch name) then your tests will report the same status. If you would like a patch to run in the context of this PR and abort the other(s), comment 'evergreen retry'. |
There was a problem hiding this comment.
[nit] We should use github.com/stretchr/testify/require to match the rest of the driver test suite.
There was a problem hiding this comment.
[question] Why not use the latest version? 1.20 is EOL.
There was a problem hiding this comment.
The rationale is to use a minimum requirement while supporting the earliest aws-sdk-go-v2 version that is compatible with the current aws.Credentials. Therefore, aws-sdk-go-v2 v1.28.0 is used and it requires golang 1.20.
There was a problem hiding this comment.
Under Minimal Version Selection, requiring aws-sdk-go-v2 v1.28.0 only means "at least v1.28.0." Any user who already depends on a newer SDK will have MVS select that higher version automatically. Pinning the minimum compatible version imposes the least constraint on downstream users.
go 1.20 is a minimum language level, not a build toolchain. The directive is inherited from aws-sdk-go-v2 v1.28.0's own go 1.20 and just declares the minimum language features the module uses. Users still build with their own (newer) toolchain. Declaring go 1.20 simply maximizes how broadly this submodule can be imported. It doesn't apply the way it would to actually compiling with an EOL compiler.
This is also consistent with the intent of splitting ext/awsauth into its own module (not forcing the AWS SDK onto core driver users) and with the driver's generally conservative Go-version policy.
There was a problem hiding this comment.
The AWS version isn't tied to which version of Go we use. We should use a Go version that is currently being supported so that we don't have issues with dependabot trying to bump dependencies due to CVEs, etc. This is an experimental API, I would wait to see if we have a consumer complain about it first. Besides, the code is very copyable.
There was a problem hiding this comment.
[question] This test intentionally skips assume-role and regular. We should update this comment to reflect that and also why we skip these cases.
🧪 Performance ResultsCommit SHA: e3d48e7The following benchmark tests for version 6a63cfdcd669c7000763c54d had statistically significant changes (i.e., |z-score| > 1.96):
For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch. |
API Change Report./v2/mongo/optionscompatible changes(*AutoEncryptionOptions).SetAWSCredentialsProvider: added ./v2/x/mongo/driver/mongocrypt/optionscompatible changesMongoCryptOptions.AWSCredentialsProvider: added |
| provider := aws.CredentialsProviderFunc(func(context.Context) (aws.Credentials, error) { | ||
| return aws.Credentials{}, nil |
There was a problem hiding this comment.
[blocking] It's unclear to me why we would need to go through the entire compile check with this separate option. We should revert these changes and simply rely on ext/awsauth/test and ext/awsauth/examples.
| // not use this file except in compliance with the License. You may obtain | ||
| // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| package awsauthtest |
There was a problem hiding this comment.
[blocking] We should add a test/compilecheck/ package here and tie it into the compile-check evergreen task:
var _ options.AWSCredentialsProvider = (*awsauth.CredentialsProvider)(nil)
GODRIVER-3567
GODRIVER-3615
Summary
This PR allows users to plug a custom AWS SDK v2 credentials provider into the driver's MONGODB-AWS authentication mechanism without forcing the AWS SDK as a dependency on the core driver.
Additionally, EKS Pod Identity and other AWS SDK-native authentication are made possible by the
ext/awsauthsubmodule as required in GODRIVER-3571.The custom provider overrides environment variables and all automatic sources, superseded only by explicit URI credentials as required in GODRIVER-3615.
Background & Motivation
This PR contains two stacked commits.
881bc5f:
New public interface in mongo/options (clientoptions.go)
AWSCredentialsProviderinterface (Retrieve(ctx) (AWSCredentials, error)) and anAWSCredentialsstruct alias.WSCredentialsProviderfield intoCredential, and intoClientEncryptionOptions/AutoEncryptionOptions.New
ext/awsauthsub moduleNewCredentialsProvider(aws.CredentialsProvider)adapts an AWS SDK v2 provider to the driver'soptions.AWSCredentialsProviderinterface. The adapter relies onAWSCredentialsbeing a struct type alias soaws.Credentialsconverts directly.Internal adapter (internal/credutil/aws_options_provider.go
AWSOptionsProviderbridges the publicoptions.AWSCredentialsProviderto the driver's internalcredentials.Providertype.bbedca6:
Notes
Instead of the v1.0.0 specified in the original design, the ext/awsauth submodule depends on aws-sdk-go-v2 v1.28.0 in this PR. v1.28.0 is the earliest version that is compatible with the current Credentials struct.