In Boto3 I could provide the access key explicitly:
dynamodb_client = boto3.resource("dynamodb",
region_name=...,
aws_access_key_id=...,
aws_secret_access_key=...)
How can I achieve the same in Rust?
I only see a function that reads it from env (~/.aws/credentials
):
let shared_config: SdkConfig = aws_config::load_from_env().await;
Standard caveat applies: please don't use hardcoded credentials unless absolutely necessary - it isn't secure.
Use the
aws-credential-types
dependency with thehardcoded-credentials
feature enabled. This will allow you to use theCredentials::from_keys
method:Here is a complete yet minimal working Rust CLI app to demonstrate the above: