All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.carlspring.cloud.storage.s3fs.S3AwsRegionProviderChain Maven / Gradle / Ivy

The newest version!
package org.carlspring.cloud.storage.s3fs;

import java.util.function.Supplier;

import software.amazon.awssdk.profiles.ProfileFile;
import software.amazon.awssdk.regions.providers.AwsProfileRegionProvider;
import software.amazon.awssdk.regions.providers.AwsRegionProviderChain;
import software.amazon.awssdk.regions.providers.SystemSettingsRegionProvider;

/**
 * AWS Region provider that looks for the region in this order:
 * 
    *
  1. Check the 'aws.region' system property for the region.
  2. *
  3. Check the 'AWS_REGION' environment variable for the region.
  4. *
  5. Check the {user.home}/.aws/credentials and {user.home}/.aws/config files for the region.
  6. *
*/ public class S3AwsRegionProviderChain extends AwsRegionProviderChain { private S3AwsRegionProviderChain(final S3AwsRegionProviderChain.Builder builder) { super(new SystemSettingsRegionProvider(), new AwsProfileRegionProvider(builder.profileFile, builder.profileName)); } public static S3AwsRegionProviderChain.Builder builder() { return new S3AwsRegionProviderChain.Builder(); } public static final class Builder { private Supplier profileFile; private String profileName; private Builder() { } public Builder profileFile(final Supplier profileFile) { this.profileFile = profileFile; return this; } public Builder profileName(final String profileName) { this.profileName = profileName; return this; } public S3AwsRegionProviderChain build() { return new S3AwsRegionProviderChain(this); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy