|
1 | 1 | <!-- Do not manually edit this file. Use the `changelogger` tool. -->
|
| 2 | +January 26th, 2023 |
| 3 | +================== |
| 4 | +**Breaking Changes:** |
| 5 | +- ⚠ ([smithy-rs#2122](https://github.com/awslabs/smithy-rs/issues/2122), [smithy-rs#2227](https://github.com/awslabs/smithy-rs/issues/2227)) Improve SDK credentials caching through type safety. `LazyCachingCredentialsProvider` has been renamed to `LazyCredentialsCache` and is no longer treated as a credentials provider. Furthermore, you do not create a `LazyCredentialsCache` directly, and instead you interact with `CredentialsCache`. This introduces the following breaking changes. |
| 6 | + |
| 7 | + If you previously used `LazyCachingCredentialsProvider`, you can replace it with `CredentialsCache`. |
| 8 | + <details> |
| 9 | + <summary>Example</summary> |
| 10 | + |
| 11 | + Before: |
| 12 | + ```rust |
| 13 | + use aws_config::meta::credentials::lazy_caching::LazyCachingCredentialsProvider; |
| 14 | + use aws_types::provider::ProvideCredentials; |
| 15 | + |
| 16 | + fn make_provider() -> impl ProvideCredentials { |
| 17 | + // --snip-- |
| 18 | + } |
| 19 | + |
| 20 | + let credentials_provider = |
| 21 | + LazyCachingCredentialsProvider::builder() |
| 22 | + .load(make_provider()) |
| 23 | + .build(); |
| 24 | + |
| 25 | + let sdk_config = aws_config::from_env() |
| 26 | + .credentials_provider(credentials_provider) |
| 27 | + .load() |
| 28 | + .await; |
| 29 | + |
| 30 | + let client = aws_sdk_s3::Client::new(&sdk_config); |
| 31 | + ``` |
| 32 | + |
| 33 | + After: |
| 34 | + ```rust |
| 35 | + use aws_credential_types::cache::CredentialsCache; |
| 36 | + use aws_types::provider::ProvideCredentials; |
| 37 | + |
| 38 | + fn make_provider() -> impl ProvideCredentials { |
| 39 | + // --snip-- |
| 40 | + } |
| 41 | + |
| 42 | + // Wrapping a result of `make_provider` in `LazyCredentialsCache` is done automatically. |
| 43 | + let sdk_config = aws_config::from_env() |
| 44 | + .credentials_cache(CredentialsCache::lazy()) // This line can be omitted because it is on by default. |
| 45 | + .credentials_provider(make_provider()) |
| 46 | + .load() |
| 47 | + .await; |
| 48 | + |
| 49 | + let client = aws_sdk_s3::Client::new(&sdk_config); |
| 50 | + ``` |
| 51 | + |
| 52 | + If you previously configured a `LazyCachingCredentialsProvider`, you can use the builder for `LazyCredentialsCache` instead. |
| 53 | + |
| 54 | + Before: |
| 55 | + ```rust |
| 56 | + use aws_config::meta::credentials::lazy_caching::LazyCachingCredentialsProvider; |
| 57 | + use aws_types::provider::ProvideCredentials; |
| 58 | + use std::time::Duration; |
| 59 | + |
| 60 | + fn make_provider() -> impl ProvideCredentials { |
| 61 | + // --snip-- |
| 62 | + } |
| 63 | + |
| 64 | + let credentials_provider = |
| 65 | + LazyCachingCredentialsProvider::builder() |
| 66 | + .load(make_provider()) |
| 67 | + .load_timeout(Duration::from_secs(60)) // Configures timeout. |
| 68 | + .build(); |
| 69 | + |
| 70 | + let sdk_config = aws_config::from_env() |
| 71 | + .credentials_provider(credentials_provider) |
| 72 | + .load() |
| 73 | + .await; |
| 74 | + |
| 75 | + let client = aws_sdk_s3::Client::new(&sdk_config); |
| 76 | + ``` |
| 77 | + |
| 78 | + After: |
| 79 | + ```rust |
| 80 | + use aws_credential_types::cache::CredentialsCache; |
| 81 | + use aws_types::provider::ProvideCredentials; |
| 82 | + use std::time::Duration; |
| 83 | + |
| 84 | + fn make_provider() -> impl ProvideCredentials { |
| 85 | + // --snip-- |
| 86 | + } |
| 87 | + |
| 88 | + let sdk_config = aws_config::from_env() |
| 89 | + .credentials_cache( |
| 90 | + CredentialsCache::lazy_builder() |
| 91 | + .load_timeout(Duration::from_secs(60)) // Configures timeout. |
| 92 | + .into_credentials_cache(), |
| 93 | + ) |
| 94 | + .credentials_provider(make_provider()) |
| 95 | + .load() |
| 96 | + .await; |
| 97 | + |
| 98 | + let client = aws_sdk_s3::Client::new(&sdk_config); |
| 99 | + ``` |
| 100 | + |
| 101 | + The examples above only demonstrate how to use `credentials_cache` and `credentials_provider` methods on `aws_config::ConfigLoader` but the same code update can be applied when you interact with `aws_types::sdk_config::Builder` or the builder for a service-specific config, e.g. `aws_sdk_s3::config::Builder`. |
| 102 | + |
| 103 | + </details> |
| 104 | + |
| 105 | + |
| 106 | + If you previously configured a `DefaultCredentialsChain` by calling `load_timeout`, `buffer_time`, or `default_credential_expiration` on its builder, you need to call the same set of methods on the builder for `LazyCredentialsCache` instead. |
| 107 | + <details> |
| 108 | + <summary>Example</summary> |
| 109 | + |
| 110 | + Before: |
| 111 | + ```rust |
| 112 | + use aws_config::default_provider::credentials::DefaultCredentialsChain; |
| 113 | + use std::time::Duration; |
| 114 | + |
| 115 | + let credentials_provider = DefaultCredentialsChain::builder() |
| 116 | + .buffer_time(Duration::from_secs(30)) |
| 117 | + .default_credential_expiration(Duration::from_secs(20 * 60)) |
| 118 | + .build() |
| 119 | + .await; |
| 120 | + |
| 121 | + let sdk_config = aws_config::from_env() |
| 122 | + .credentials_provider(credentials_provider) |
| 123 | + .load() |
| 124 | + .await; |
| 125 | + |
| 126 | + let client = aws_sdk_s3::Client::new(&sdk_config); |
| 127 | + ``` |
| 128 | + |
| 129 | + After: |
| 130 | + ```rust |
| 131 | + use aws_config::default_provider::credentials::default_provider; |
| 132 | + use aws_credential_types::cache::CredentialsCache; |
| 133 | + use std::time::Duration; |
| 134 | + |
| 135 | + // Previously used methods no longer exist on the builder for `DefaultCredentialsChain`. |
| 136 | + let credentials_provider = default_provider().await; |
| 137 | + |
| 138 | + let sdk_config = aws_config::from_env() |
| 139 | + .credentials_cache( |
| 140 | + CredentialsCache::lazy_builder() |
| 141 | + .buffer_time(Duration::from_secs(30)) |
| 142 | + .default_credential_expiration(Duration::from_secs(20 * 60)) |
| 143 | + .into_credentials_cache(), |
| 144 | + ) |
| 145 | + .credentials_provider(credentials_provider) |
| 146 | + .load() |
| 147 | + .await; |
| 148 | + |
| 149 | + let client = aws_sdk_s3::Client::new(&sdk_config); |
| 150 | + ``` |
| 151 | + |
| 152 | + </details> |
| 153 | +- ⚠ ([smithy-rs#2122](https://github.com/awslabs/smithy-rs/issues/2122), [smithy-rs#2227](https://github.com/awslabs/smithy-rs/issues/2227)) The introduction of `CredentialsCache` comes with an accompanying type `SharedCredentialsCache`, which we will store in the property bag instead of a `SharedCredentialsProvider`. As a result, `aws_http::auth:set_provider` has been updated to `aws_http::auth::set_credentials_cache`. |
| 154 | + |
| 155 | + Before: |
| 156 | + ```rust |
| 157 | + use aws_credential_types::Credentials; |
| 158 | + use aws_credential_types::provider::SharedCredentialsProvider; |
| 159 | + use aws_http::auth::set_provider; |
| 160 | + use aws_smithy_http::body::SdkBody; |
| 161 | + use aws_smithy_http::operation; |
| 162 | + |
| 163 | + let mut req = operation::Request::new(http::Request::new(SdkBody::from("some body"))); |
| 164 | + let credentials = Credentials::new("example", "example", None, None, "my_provider_name"); |
| 165 | + set_provider( |
| 166 | + &mut req.properties_mut(), |
| 167 | + SharedCredentialsProvider::new(credentials), |
| 168 | + ); |
| 169 | + ``` |
| 170 | + |
| 171 | + After: |
| 172 | + ```rust |
| 173 | + use aws_credential_types::Credentials; |
| 174 | + use aws_credential_types::cache::{CredentialsCache, SharedCredentialsCache}; |
| 175 | + use aws_credential_types::provider::SharedCredentialsProvider; |
| 176 | + use aws_http::auth::set_credentials_cache; |
| 177 | + use aws_smithy_http::body::SdkBody; |
| 178 | + use aws_smithy_http::operation; |
| 179 | + |
| 180 | + let mut req = operation::Request::new(http::Request::new(SdkBody::from("some body"))); |
| 181 | + let credentials = Credentials::new("example", "example", None, None, "my_provider_name"); |
| 182 | + let credentials_cache = CredentialsCache::lazy_builder() |
| 183 | + .into_credentials_cache() |
| 184 | + .create_cache(SharedCredentialsProvider::new(credentials)); |
| 185 | + set_credentials_cache( |
| 186 | + &mut req.properties_mut(), |
| 187 | + SharedCredentialsCache::new(credentials_cache), |
| 188 | + ); |
| 189 | + ``` |
| 190 | + |
| 191 | +**New this release:** |
| 192 | +- 🐛 ([smithy-rs#2204](https://github.com/awslabs/smithy-rs/issues/2204)) Fix endpoint for s3.write_get_object_response(). This bug was introduced in 0.53. |
| 193 | +- ([smithy-rs#2204](https://github.com/awslabs/smithy-rs/issues/2204)) Add `with_test_defaults()` and `set_test_defaults()` to `<service>::Config`. These methods fill in defaults for configuration that is mandatory to successfully send a request. |
| 194 | + |
| 195 | + |
2 | 196 | January 13th, 2023
|
3 | 197 | ==================
|
4 | 198 | **Breaking Changes:**
|
|
0 commit comments