Struct object_store::aws::AmazonS3Builder

source ·
pub struct AmazonS3Builder { /* private fields */ }
Expand description

Configure a connection to Amazon S3 using the specified credentials in the specified Amazon region and bucket.

§Example

let s3 = AmazonS3Builder::new()
 .with_region(REGION)
 .with_bucket_name(BUCKET_NAME)
 .with_access_key_id(ACCESS_KEY_ID)
 .with_secret_access_key(SECRET_KEY)
 .build();

Implementations§

source§

impl AmazonS3Builder

source

pub fn new() -> Self

Create a new AmazonS3Builder with default values.

source

pub fn from_env() -> Self

Fill the AmazonS3Builder with regular AWS environment variables

Variables extracted from environment:

§Example
use object_store::aws::AmazonS3Builder;

let s3 = AmazonS3Builder::from_env()
    .with_bucket_name("foo")
    .build();
source

pub fn with_url(self, url: impl Into<String>) -> Self

Parse available connection info form a well-known storage URL.

The supported url schemes are:

  • s3://<bucket>/<path>
  • s3a://<bucket>/<path>
  • https://s3.<region>.amazonaws.com/<bucket>
  • https://<bucket>.s3.<region>.amazonaws.com
  • https://ACCOUNT_ID.r2.cloudflarestorage.com/bucket

Note: Settings derived from the URL will override any others set on this builder

§Example
use object_store::aws::AmazonS3Builder;

let s3 = AmazonS3Builder::from_env()
    .with_url("s3://bucket/path")
    .build();
source

pub fn with_config( self, key: AmazonS3ConfigKey, value: impl Into<String>, ) -> Self

Set an option on the builder via a key - value pair.

source

pub fn get_config_value(&self, key: &AmazonS3ConfigKey) -> Option<String>

Get config value via a AmazonS3ConfigKey.

§Example
use object_store::aws::{AmazonS3Builder, AmazonS3ConfigKey};

let builder = AmazonS3Builder::from_env()
    .with_bucket_name("foo");
let bucket_name = builder.get_config_value(&AmazonS3ConfigKey::Bucket).unwrap_or_default();
assert_eq!("foo", &bucket_name);
source

pub fn with_access_key_id(self, access_key_id: impl Into<String>) -> Self

Set the AWS Access Key

source

pub fn with_secret_access_key( self, secret_access_key: impl Into<String>, ) -> Self

Set the AWS Secret Access Key

source

pub fn with_token(self, token: impl Into<String>) -> Self

Set the AWS Session Token to use for requests

source

pub fn with_region(self, region: impl Into<String>) -> Self

Set the region, defaults to us-east-1

source

pub fn with_bucket_name(self, bucket_name: impl Into<String>) -> Self

Set the bucket_name (required)

source

pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self

Sets the endpoint for communicating with AWS S3, defaults to the region endpoint

For example, this might be set to "http://localhost:4566: for testing against a localstack instance.

The endpoint field should be consistent with Self::with_virtual_hosted_style_request, i.e. if virtual_hosted_style_request is set to true then endpoint should have the bucket name included.

By default, only HTTPS schemes are enabled. To connect to an HTTP endpoint, enable Self::with_allow_http.

source

pub fn with_credentials(self, credentials: AwsCredentialProvider) -> Self

Set the credential provider overriding any other options

source

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
source

pub fn with_virtual_hosted_style_request( self, virtual_hosted_style_request: bool, ) -> Self

Sets if virtual hosted style request has to be used.

If virtual_hosted_style_request is:

  • false (default): Path style request is used
  • true: Virtual hosted style request is used

If the endpoint is provided then it should be consistent with virtual_hosted_style_request. i.e. if virtual_hosted_style_request is set to true then endpoint should have bucket name included.

source

pub fn with_s3_express(self, s3_express: bool) -> Self

Configure this as an S3 Express One Zone Bucket

source

pub fn with_retry(self, retry_config: RetryConfig) -> Self

Set the retry configuration

source

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.

This option has no effect if not using instance credentials

source

pub fn with_unsigned_payload(self, unsigned_payload: bool) -> Self

Sets if unsigned payload option has to be used. See unsigned payload option

  • false (default): Signed payload option is used, where the checksum for the request body is computed and included when constructing a canonical request.
  • true: Unsigned payload option is used. UNSIGNED-PAYLOAD literal is included when constructing a canonical request,
source

pub fn with_skip_signature(self, skip_signature: bool) -> Self

If enabled, AmazonS3 will not fetch credentials and will not sign requests

This can be useful when interacting with public S3 buckets that deny authorized requests

source

pub fn with_checksum_algorithm(self, checksum_algorithm: Checksum) -> Self

Sets the checksum algorithm which has to be used for object integrity check during upload.

source

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.

source

pub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self

Set the proxy_url to be used by the underlying client

source

pub fn with_proxy_ca_certificate( self, proxy_ca_certificate: impl Into<String>, ) -> Self

Set a trusted proxy CA certificate

source

pub fn with_proxy_excludes(self, proxy_excludes: impl Into<String>) -> Self

Set a list of hosts to exclude from proxy connections

source

pub fn with_client_options(self, options: ClientOptions) -> Self

Sets the client options, overriding any already set

source

pub fn with_copy_if_not_exists(self, config: S3CopyIfNotExists) -> Self

Configure how to provide copy_if_not_exists

source

pub fn with_conditional_put(self, config: S3ConditionalPut) -> Self

Configure how to provide conditional put operations

source

pub fn with_disable_tagging(self, ignore: bool) -> Self

If set to true will ignore any tags provided to put_opts

source

pub fn with_sse_kms_encryption(self, kms_key_id: impl Into<String>) -> Self

Use SSE-KMS for server side encryption.

source

pub fn with_dsse_kms_encryption(self, kms_key_id: impl Into<String>) -> Self

Use dual server side encryption for server side encryption.

source

pub fn with_bucket_key(self, enabled: bool) -> Self

Set whether to enable bucket key for server side encryption. This overrides the bucket default setting for bucket keys.

When bucket keys are disabled, each object is encrypted with a unique data key. When bucket keys are enabled, a single data key is used for the entire bucket, reducing overhead of encryption.

source

pub fn build(self) -> Result<AmazonS3>

Create a AmazonS3 instance from the provided values, consuming self.

Trait Implementations§

source§

impl Clone for AmazonS3Builder

source§

fn clone(&self) -> AmazonS3Builder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AmazonS3Builder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AmazonS3Builder

source§

fn default() -> AmazonS3Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more