/** * Attempt to determine the region from the configured region provider. This will return null in the event that the * region provider could not determine the region automatically. */ private String determineRegionFromRegionProvider() { try { return DEFAULT_REGION_PROVIDER.getRegion(); } catch (SdkClientException e) { // The AwsRegionProviderChain that is used by default throws an exception instead of returning null when // the region is not defined. For that reason, we have to support both throwing an exception and returning // null as the region not being defined. return null; } }
/** * Attempt to determine the region from the configured region provider. This will return null in the event that the * region provider could not determine the region automatically. */ private String determineRegionFromRegionProvider() { try { return regionProvider.getRegion(); } catch (SdkClientException e) { // The AwsRegionProviderChain that is used by default throws an exception instead of returning null when // the region is not defined. For that reason, we have to support both throwing an exception and returning // null as the region not being defined. return null; } }
@Override public String getRegion() throws SdkClientException { for (AwsRegionProvider provider : providers) { try { final String region = provider.getRegion(); if (region != null) { return region; } } catch (Exception e) { // Ignore any exceptions and move onto the next provider LOG.debug("Unable to load region from " + provider.toString() + ": " + e.getMessage()); } } // Note: This is a bug in the provider chain. The chain should return null when no region is found according to // the interface, but an exception is thrown here instead. This class is used in too many places to change now. // TODO: In 2.0, be sure this bug does not carry through. throw new SdkClientException("Unable to load region information from any provider in the chain"); } }
/** * Attempt to determine the region from the configured region provider. This will return null in the event that the * region provider could not determine the region automatically. */ private String determineRegionFromRegionProvider() { try { return regionProvider.getRegion(); } catch (SdkClientException e) { // The AwsRegionProviderChain that is used by default throws an exception instead of returning null when // the region is not defined. For that reason, we have to support both throwing an exception and returning // null as the region not being defined. return null; } }
@Override public String getRegion() throws SdkClientException { for (AwsRegionProvider provider : providers) { try { final String region = provider.getRegion(); if (region != null) { return region; } } catch (Exception e) { // Ignore any exceptions and move onto the next provider LOG.debug("Unable to load region from " + provider.toString() + ": " + e.getMessage()); } } // Note: This is a bug in the provider chain. The chain should return null when no region is found according to // the interface, but an exception is thrown here instead. This class is used in too many places to change now. // TODO: In 2.0, be sure this bug does not carry through. throw new SdkClientException("Unable to load region information from any provider in the chain"); } }
/** * Attempt to determine the region from the configured region provider. This will return null in the event that the * region provider could not determine the region automatically. */ private String determineRegionFromRegionProvider() { try { return DEFAULT_REGION_PROVIDER.getRegion(); } catch (SdkClientException e) { // The AwsRegionProviderChain that is used by default throws an exception instead of returning null when // the region is not defined. For that reason, we have to support both throwing an exception and returning // null as the region not being defined. return null; } }
/** * Attempt to determine the region from the configured region provider. This will return null in the event that the * region provider could not determine the region automatically. */ private String determineRegionFromRegionProvider() { try { return regionProvider.getRegion(); } catch (SdkClientException e) { // The AwsRegionProviderChain that is used by default throws an exception instead of returning null when // the region is not defined. For that reason, we have to support both throwing an exception and returning // null as the region not being defined. return null; } }
@Override public String getRegion() throws SdkClientException { for (AwsRegionProvider provider : providers) { try { final String region = provider.getRegion(); if (region != null) { return region; } } catch (Exception e) { // Ignore any exceptions and move onto the next provider LOG.debug("Unable to load region from " + provider.toString() + ": " + e.getMessage()); } } // Note: This is a bug in the provider chain. The chain should return null when no region is found according to // the interface, but an exception is thrown here instead. This class is used in too many places to change now. // TODO: In 2.0, be sure this bug does not carry through. throw new SdkClientException("Unable to load region information from any provider in the chain"); } }
/** * Constructor * @param config - Configuration map */ public S3Helper(Map<String, Object> config) { AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard(); if(config.containsKey(ACCESS_KEY_ID_CONFIG) && config.containsKey(SECRET_KEY_CONFIG)) { builder.withCredentials( new AWSStaticCredentialsProvider( new BasicAWSCredentials( config.get(ACCESS_KEY_ID_CONFIG).toString(), config.get(SECRET_KEY_CONFIG).toString()))); } else { builder.withCredentials(DefaultAWSCredentialsProviderChain.getInstance()); } if(config.containsKey(REGION_CONFIG)) { builder.withRegion(config.get(REGION_CONFIG).toString()); } else { AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain(); builder.withRegion(regionProvider.getRegion()); } s3 = builder.build(); exceptionOnError = (boolean) config.getOrDefault(EXCEPTION_ON_ERROR_CONFIG, EXCEPTION_ON_ERROR_DEFAULT); }
tmpRegion = regionProvider.getRegion(); } catch (final SdkClientException e) { tmpRegion = Regions.getCurrentRegion() != null