String region = "us-west-2"; AwsClientBuilder.EndpointConfiguration config = new AwsClientBuilder.EndpointConfiguration(endpoint, region); AWSSecretsManagerClientBuilder clientBuilder = AWSSecretsManagerClientBuilder.standard(); clientBuilder.setEndpointConfiguration(config);
private void setRegion(AmazonWebServiceClient client) { if (region != null && endpointConfiguration != null) { throw new IllegalStateException("Only one of Region or EndpointConfiguration may be set."); } if (endpointConfiguration != null) { client.setEndpoint(endpointConfiguration.getServiceEndpoint()); client.setSignerRegionOverride(endpointConfiguration.getSigningRegion()); } else if (region != null) { client.setRegion(region); } else { final String region = determineRegionFromRegionProvider(); if (region != null) { client.setRegion(getRegionObject(region)); } else { throw new SdkClientException( "Unable to find a region via the region provider chain. " + "Must provide an explicit region in the builder or setup environment to supply a region."); } } }
builder = builder.withRegion(bl); } else if (s3Target != null) { EndpointConfiguration ep = new EndpointConfiguration(s3Target, "us-east-1"); builder = builder.withEndpointConfiguration(ep); System.out.println("target=" + s3Target);
new AwsClientBuilder.EndpointConfiguration( config.getEndpoint(),
amazonS3ClientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null)); amazonS3ClientBuilder.setPathStyleAccessEnabled(true); } else {
properties.put(DynamoDBStreamsConnectorConfiguration.PROP_DYNAMODB_ENDPOINT, destinationEndpointConfiguration.getServiceEndpoint()); properties.put(DynamoDBStreamsConnectorConfiguration.PROP_DYNAMODB_DATA_TABLE_NAME, destinationTable); properties.put(DynamoDBStreamsConnectorConfiguration.PROP_REGION_NAME, destinationRegion.getName());
clientBuilder.withEndpointConfiguration(new EndpointConfiguration(endpoint, null)); regionOrEndpointSet = true;
clientBuilder = clientBuilder.withEndpointConfiguration(new EndpointConfiguration(endpoint, null)); regionOrEndpointSet = true;
builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, finalRegion));
"if both is specified only the endpoint will be in effect."); builder.setEndpointConfiguration(new EndpointConfiguration(endpoint.get(), null)); builder.setEndpointConfiguration(new EndpointConfiguration("s3.amazonaws.com", null));
LOGGER.debug("Creating DynamoDb standard client with endpoint [{}] and region [{}]", props.getEndpoint(), props.getRegion()); val endpoint = new AwsClientBuilder.EndpointConfiguration( props.getEndpoint(), props.getRegion()); return AmazonDynamoDBClientBuilder.standard() clientBuilder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(props.getEndpoint(), region));
.withConnectionTimeout(1000)) .withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(url, Regions.DEFAULT_REGION.getName())) .build();
/** * Create the builder ready for any final configuration options. * Picks up connection settings from the Hadoop configuration, including * proxy secrets. * @param conf Configuration to act as source of options. * @param bucket Optional bucket to use to look up per-bucket proxy secrets * @param credentials AWS credential chain to use * @param stsEndpoint optional endpoint "https://sns.us-west-1.amazonaws.com" * @param stsRegion the region, e.g "us-west-1" * @return the builder to call {@code build()} * @throws IOException problem reading proxy secrets */ public static AWSSecurityTokenServiceClientBuilder builder( final Configuration conf, final String bucket, final AWSCredentialsProvider credentials, final String stsEndpoint, final String stsRegion) throws IOException { Preconditions.checkArgument(credentials != null, "No credentials"); final AWSSecurityTokenServiceClientBuilder builder = AWSSecurityTokenServiceClientBuilder.standard(); final ClientConfiguration awsConf = S3AUtils.createAwsConf(conf, bucket); builder.withClientConfiguration(awsConf); builder.withCredentials(credentials); if (StringUtils.isNotEmpty(stsEndpoint)) { LOG.debug("STS Endpoint ={}", stsEndpoint); builder.withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(stsEndpoint, stsRegion)); } return builder; }
builder = builder.withEndpointConfiguration(new EndpointConfiguration( endpoint, clientRegion)); builder = builder.withPathStyleAccessEnabled(pathStyleAccess);
/** * Returns a client instance for AWS DynamoDB. * @return a client that talks to DynamoDB */ public static AmazonDynamoDB getClient() { if (ddbClient != null) { return ddbClient; } if (Config.IN_PRODUCTION) { ddbClient = AmazonDynamoDBClientBuilder.standard().build(); } else { ddbClient = AmazonDynamoDBClientBuilder.standard(). withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("local", "null"))). withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build(); } if (!existsTable(Config.getRootAppIdentifier())) { createTable(Config.getRootAppIdentifier()); } ddb = new DynamoDB(ddbClient); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return ddbClient; }
/** * Returns a client instance for AWS DynamoDB. * @return a client that talks to DynamoDB */ public static AmazonDynamoDB getClient() { if (ddbClient != null) { return ddbClient; } if (Config.IN_PRODUCTION) { ddbClient = AmazonDynamoDBClientBuilder.standard().build(); } else { ddbClient = AmazonDynamoDBClientBuilder.standard(). withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("local", "null"))). withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build(); } if (!existsTable(Config.getRootAppIdentifier())) { createTable(Config.getRootAppIdentifier()); } ddb = new DynamoDB(ddbClient); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return ddbClient; }
<R, T extends AwsClientBuilder<T, R>> R createClient(final T builder, final AWSCredentialsProvider credentialsProvider, final ClientConfiguration clientConfiguration, final String endpointUrl, final String region) { if (credentialsProvider != null) { builder.withCredentials(credentialsProvider); } if (clientConfiguration != null) { builder.withClientConfiguration(clientConfiguration); } if (StringUtils.isNotEmpty(endpointUrl)) { LOG.warn("Received configuration for endpoint as " + endpointUrl + ", and region as " + region + "."); builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpointUrl, region)); } else if (StringUtils.isNotEmpty(region)) { LOG.warn("Received configuration for region as " + region + "."); builder.withRegion(region); } else { LOG.warn("No configuration received for endpoint and region, will default region to us-east-1"); builder.withRegion(Regions.US_EAST_1); } return builder.build(); } }
@Provides @LazySingleton public ServerSideEncryptingAmazonS3 getAmazonS3Client( AWSCredentialsProvider provider, AWSProxyConfig proxyConfig, AWSEndpointConfig endpointConfig, AWSClientConfig clientConfig, S3StorageConfig storageConfig ) { final ClientConfiguration configuration = new ClientConfigurationFactory().getConfig(); final AmazonS3ClientBuilder builder = AmazonS3Client .builder() .withCredentials(provider) .withClientConfiguration(setProxyConfig(configuration, proxyConfig)) .withChunkedEncodingDisabled(clientConfig.isDisableChunkedEncoding()) .withPathStyleAccessEnabled(clientConfig.isEnablePathStyleAccess()) .withForceGlobalBucketAccessEnabled(clientConfig.isForceGlobalBucketAccessEnabled()); if (StringUtils.isNotEmpty(endpointConfig.getUrl())) { builder.setEndpointConfiguration( new EndpointConfiguration(endpointConfig.getUrl(), endpointConfig.getSigningRegion()) ); } return new ServerSideEncryptingAmazonS3( builder.build(), storageConfig.getServerSideEncryption() ); }
private static Connector createClient(Map<String, Object> cfg) { String url = (String) cfg.get("url"); String accessKey = (String) cfg.get("accessKey"); String secretKey = (String) cfg.get("secretKey"); String bucketName = (String) cfg.get("bucketName"); Supplier<AmazonS3> client = () -> { log.info("createClient -> connecting to {}...", url); AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AmazonS3 s3 = AmazonS3ClientBuilder.standard() .withClientConfiguration(new ClientConfiguration()) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, "other-v2-signature")) .withCredentials(new AWSStaticCredentialsProvider(credentials)) .enablePathStyleAccess() .build(); try { createBucket(s3, bucketName); } catch (Exception e) { log.error("createClient -> error while creating buckets", e); throw e; } return s3; }; return new Connector(client, bucketName); }
public void init(boolean connect) { AWSCredentials credentials; if (!Strings.isNullOrEmpty(accessKey) || !Strings.isNullOrEmpty(secretKey)) { credentials = new BasicAWSCredentials(accessKey, secretKey); } else { credentials = new AnonymousAWSCredentials(); } AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(credentials)) .withClientConfiguration(new ClientConfiguration() .withMaxConnections(Runtime.getRuntime().availableProcessors() * 10) .withMaxErrorRetry(50)); if (!Strings.isNullOrEmpty(region)) { builder = builder.withRegion(region); } if (!Strings.isNullOrEmpty(endpoint)) { builder = builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null)); } this.client = builder.build(); if (connect) { // testing connection this.client.listObjects(bucket); } }