Recently I was working with aws-sdk-dynamodb was trying to initialize the client by passing the values for DynamoDB client so that I can have static initialization of credentials
pub static ref DB_AWS: AsyncOnce<Client> = AsyncOnce::new(async {
// use aws_types::sdk_config::Builder;
let region = KEY_MAP
.get(&"aws_region".to_string())
.unwrap_or(&"ap-south-1".to_string())
.to_owned();
let url = KEY_MAP
.get(&"aws_region_url".to_string())
.unwrap_or(&format!("https://dynamodb.{}.amazonaws.com/", region))
.to_owned()
.parse::<Uri>()
.unwrap();
let AK = KEY_MAP.get(&"db-access-key".to_string()).unwrap();
let sec_ak = KEY_MAP.get(&"db-secret-access-key".to_string()).unwrap();
// let creds = Credentials::from_keys(AK, sec_ak, None);
// creds values are initialized
let db_creds = aws_sdk_dynamodb::Credentials::new(AK, sec_ak, None, None, "AWS");
//values are passed to the builder
let mut dynamodb_local_config = aws_sdk_dynamodb::config::Builder::new()
.retry_config(RetryConfig::new().with_max_attempts(2))
.credentials_provider(db_creds)
.region(Region::new(region))
.endpoint_resolver(Endpoint::immutable(url));
dynamodb_local_config.set_sleep_impl(None);
let client = Client::from_conf(dynamodb_local_config.build());
return client;
});
and warning I get during the runtime while trying to though it compiles flawlessly
but still the credentials of aws passed to it doesn't makes any calls
here is the warning
WARN aws_smithy_client::builder: Retries require a `sleep_impl`, but none was passed into the builder. No retries will occur with the current configuration. If this was intentional, you can suppress this message with `Client::set_sleep_impl(None). Otherwise, unless you have a good reason to use the low-level service client API, consider using the `aws-config` crate to load a shared config from the environment, and construct a fluent client from that.
If you need to use the low-level service client API, then pass in a sleep implementation to make timeouts and retry work.
Can somebody please help me find out why these credentials are not initializing the values?
for more reference to the project you can check out my repo here