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

Minimal Support for Shared Config Loading #675

Merged
merged 13 commits into from
Aug 30, 2021
Merged

Minimal Support for Shared Config Loading #675

merged 13 commits into from
Aug 30, 2021

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Aug 30, 2021

Motivation and Context

#655

This diff adds support for region loading from the shared config. There were a few bits that needed to be moved around to make that happen. The next major piece is moving credential providers into aws-config.

Description

  • Create aws-config package
  • Move ProvideRegion to aws-config
  • Move RegionProviderChain & EnvironmentProvider to aws-config
  • Create EnvLoader in aws-config
  • Update all examples to use the new pattern. I made a lot of the examples more consistent which should help when making updates in the future.

Testing

  • Ran some examples manually

Checklist

  • I have updated the CHANGELOG

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

rcoh added 6 commits August 27, 2021 17:54
This commit adds a new AWS config module. It only currently supports region resolution. A follow up commit will remove `ProvideRegion` from AWS types.
This commit introduces `aws-config`, the configuration loader entry point for the SDK. Currently, this adds very little new code, instead, it migrates code from `aws_types` into the shared-config package.
@rcoh rcoh changed the title Aws config min Minimal Support for Shared Config Loading Aug 30, 2021
@rcoh rcoh requested a review from jdisanti August 30, 2021 18:07
/// will prevent the standard resolution chain from occuring (eg. overriding a region will prevent an HTTP request
/// to IMDS).
#[derive(Default, Debug)]
pub struct EnvLoader {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It kind of seems like this should get its own module, or some config loader module, as it is separate from the providers.

Comment on lines 28 to 30
/// This builder supports overriding individual components of the generated config. Overriding a component
/// will prevent the standard resolution chain from occuring (eg. overriding a region will prevent an HTTP request
/// to IMDS).
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is slightly confusing. I read it to mean credentials won't be retrieved from IMDS if a region is provided.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


impl ProvideRegion for RegionProviderChain {
fn region(&self) -> future::ProvideRegion {
future::ProvideRegion::new(self.region())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like it could be an infinite loop. Could we make the call to region more explicit?

providers: Vec<Box<dyn ProvideRegion>>,
}

impl RegionProviderChain {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason not to combine this impl block with the one below?

* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't look like this module is referenced anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch, result of a bad git add

@@ -50,8 +50,10 @@ fn default_connector() -> Option<DynConnector> {
/// This provider chain will use defaults for all settings. The region will be resolved with the default
/// provider chain. To construct a custom provider, use [`default_provider_chain::Builder`](default_provider_chain::Builder).
pub async fn default_provider() -> impl AsyncProvideCredentials {
use aws_types::region::ProvideRegion;
let resolved_region = aws_types::region::default_provider().region().await;
use aws_config::meta::region::ProvideRegion;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be worth it to duplicate the region method directly on the chain provider so that this import isn't necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for backwards compatibility reasons this doesn't return chain_provider it returns impl ProvideRegion

CHANGELOG.md Outdated
@@ -1,9 +1,21 @@
vNext (Month Day, Year)
-----------------------
**Breaking Changes**
- `<sevicename>::from_env()` has been removed (#675). A drop-in replacement is available:
1. Add a dependency on `aws-config`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Give an example of adding this dependency

CHANGELOG.md Outdated Show resolved Hide resolved
@rcoh rcoh requested a review from jdisanti August 30, 2021 19:40
Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

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

Looks great!

@rcoh rcoh merged commit c6143ec into main Aug 30, 2021
@rcoh rcoh deleted the aws-config-min branch August 30, 2021 22:23
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