pub struct AmazonBuilder { /* private fields */ }Expand description
Configure AWS authentication credentials.
§Example
let config = AmazonBuilder::new()
.with_region(REGION)
.with_access_key_id(ACCESS_KEY_ID)
.with_secret_access_key(SECRET_KEY)
.build(None);Implementations§
Source§impl AmazonBuilder
impl AmazonBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new AmazonBuilder with default values.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Fill the AmazonBuilder with regular AWS environment variables
Variables extracted from environment:
AWS_ACCESS_KEY_ID-> access_key_idAWS_SECRET_ACCESS_KEY-> secret_access_keyAWS_DEFAULT_REGION-> regionAWS_SESSION_TOKEN-> tokenAWS_CONTAINER_CREDENTIALS_RELATIVE_URI-> https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.htmlAWS_ALLOW_HTTP-> set to “true” to permit HTTP connections without TLS
Sourcepub fn with_config(
self,
key: AmazonS3ConfigKey,
value: impl Into<String>,
) -> Self
pub fn with_config( self, key: AmazonS3ConfigKey, value: impl Into<String>, ) -> Self
Set an option on the builder via a key - value pair.
Sourcepub fn get_config_value(&self, key: &AmazonS3ConfigKey) -> Option<String>
pub fn get_config_value(&self, key: &AmazonS3ConfigKey) -> Option<String>
Get config value via a AmazonS3ConfigKey.
Sourcepub fn with_access_key_id(self, access_key_id: impl Into<String>) -> Self
pub fn with_access_key_id(self, access_key_id: impl Into<String>) -> Self
Set the AWS Access Key
Sourcepub fn with_secret_access_key(
self,
secret_access_key: impl Into<String>,
) -> Self
pub fn with_secret_access_key( self, secret_access_key: impl Into<String>, ) -> Self
Set the AWS Secret Access Key
Sourcepub fn with_token(self, token: impl Into<String>) -> Self
pub fn with_token(self, token: impl Into<String>) -> Self
Set the AWS Session Token to use for requests
Sourcepub fn with_region(self, region: impl Into<String>) -> Self
pub fn with_region(self, region: impl Into<String>) -> Self
Set the region, defaults to us-east-1
Sourcepub fn with_credentials(self, credentials: AwsCredentialProvider) -> Self
pub fn with_credentials(self, credentials: AwsCredentialProvider) -> Self
Set the credential provider overriding any other options
Sourcepub fn with_allow_http(self, allow_http: bool) -> Self
pub fn with_allow_http(self, allow_http: bool) -> Self
Sets what protocol is allowed. If allow_http is :
- false (default): Only HTTPS are allowed
- true: HTTP and HTTPS are allowed
Sourcepub fn with_retry(self, retry_config: RetryConfig) -> Self
pub fn with_retry(self, retry_config: RetryConfig) -> Self
Set the retry configuration
Sourcepub fn with_imdsv1_fallback(self) -> Self
pub fn with_imdsv1_fallback(self) -> Self
By default instance credentials will only be fetched over IMDSv2, as AWS recommends against having IMDSv1 enabled on EC2 instances as it is vulnerable to SSRF attack
However, certain deployment environments, such as those running old versions of kube2iam, may not support IMDSv2. This option will enable automatic fallback to using IMDSv1 if the token endpoint returns a 403 error indicating that IMDSv2 is not supported.
Sourcepub fn with_skip_signature(self, skip_signature: bool) -> Self
pub fn with_skip_signature(self, skip_signature: bool) -> Self
If enabled, requests will not be signed.
Sourcepub fn with_metadata_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_metadata_endpoint(self, endpoint: impl Into<String>) -> Self
Set the instance metadata endpoint, used primarily within AWS EC2.
This defaults to the IPv4 endpoint: http://169.254.169.254. One can alternatively use the IPv6 endpoint http://fd00:ec2::254.
Sourcepub fn with_role_arn(self, role_arn: impl Into<String>) -> Self
pub fn with_role_arn(self, role_arn: impl Into<String>) -> Self
Assume the given IAM role via STS AssumeRole after obtaining base credentials.
When set, the builder resolves base credentials (static, IMDS, or WebIdentity)
and then exchanges them for temporary credentials scoped to role_arn.
§References
Sourcepub fn with_role_session_name(self, session_name: impl Into<String>) -> Self
pub fn with_role_session_name(self, session_name: impl Into<String>) -> Self
Set the session name used in AssumeRole requests (defaults to "AssumeRoleSession").
Sourcepub fn with_sts_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_sts_endpoint(self, endpoint: impl Into<String>) -> Self
Override the STS endpoint used for AssumeRole (defaults to the regional endpoint).
Sourcepub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self
pub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self
Set the proxy_url to be used by the underlying client
Sourcepub fn with_proxy_ca_certificate(
self,
proxy_ca_certificate: impl Into<String>,
) -> Self
pub fn with_proxy_ca_certificate( self, proxy_ca_certificate: impl Into<String>, ) -> Self
Set a trusted proxy CA certificate
Sourcepub fn with_proxy_excludes(self, proxy_excludes: impl Into<String>) -> Self
pub fn with_proxy_excludes(self, proxy_excludes: impl Into<String>) -> Self
Set a list of hosts to exclude from proxy connections
Sourcepub fn with_client_options(self, options: ClientOptions) -> Self
pub fn with_client_options(self, options: ClientOptions) -> Self
Sets the client options, overriding any already set
Sourcepub fn build(self, runtime: Option<&Handle>) -> Result<AmazonConfig>
pub fn build(self, runtime: Option<&Handle>) -> Result<AmazonConfig>
Build an AmazonConfig from the provided values, consuming self.
If runtime is provided, all HTTP I/O (including credential refresh)
will be spawned on the given runtime handle.
Trait Implementations§
Source§impl Clone for AmazonBuilder
impl Clone for AmazonBuilder
Source§fn clone(&self) -> AmazonBuilder
fn clone(&self) -> AmazonBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more