Example usage for com.amazonaws.regions Region getServiceEndpoint

List of usage examples for com.amazonaws.regions Region getServiceEndpoint

Introduction

In this page you can find the example usage for com.amazonaws.regions Region getServiceEndpoint.

Prototype

public String getServiceEndpoint(String endpointPrefix) 

Source Link

Document

Returns the endpoint for the service given.

Usage

From source file:io.pivotal.strepsirrhini.chaoslemur.infrastructure.InfrastructureConfiguration.java

License:Apache License

@Bean
@ConditionalOnProperty("aws.accessKeyId")
AmazonEC2Client amazonEC2(@Value("${aws.accessKeyId}") String accessKeyId,
        @Value("${aws.secretAccessKey}") String secretAccessKey,
        @Value("${aws.region:us-east-1}") String regionName) {

    AmazonEC2Client amazonEC2Client = new AmazonEC2Client(
            new BasicAWSCredentials(accessKeyId, secretAccessKey));
    Region region = Region.getRegion(Regions.fromName(regionName));
    amazonEC2Client.setEndpoint(region.getServiceEndpoint("ec2"));

    return amazonEC2Client;
}

From source file:jetbrains.buildServer.runner.cloudformation.AWSClient.java

License:Apache License

public String getTemplateUrl(Region region, String s3Bucket, String s3Object) {
    // "https://s3-us-west-2.amazonaws.com/" + s3BucketName + "/" +
    // s3ObjectKey;
    String templateUrl;//ww  w .  j  a  v  a  2  s.co  m
    // hard coded s3 bucket location
    // templateUrl = "https://s3-ap-southeast-2.amazonaws.com" + "/" + s3Bucket + "/" + s3Object;
    templateUrl = "https://" + region.getServiceEndpoint("s3") + "/" + s3Bucket + "/" + s3Object;
    return templateUrl;
}

From source file:org.apache.nifi.processors.aws.s3.AbstractS3Processor.java

License:Apache License

protected String getUrlForObject(final String bucket, final String key) {
    Region region = getRegion();

    if (region == null) {
        return DEFAULT_PROTOCOL.toString() + "://s3.amazonaws.com/" + bucket + "/" + key;
    } else {//from w  ww  .  j  a  v  a2 s  .c  o  m
        final String endpoint = region.getServiceEndpoint("s3");
        return DEFAULT_PROTOCOL.toString() + "://" + endpoint + "/" + bucket + "/" + key;
    }
}

From source file:org.springframework.cloud.aws.core.io.s3.SimpleStorageResource.java

License:Apache License

@Override
public URL getURL() throws IOException {
    if (this.amazonS3 instanceof AmazonS3Client) {
        Region region = ((AmazonS3Client) this.amazonS3).getRegion().toAWSRegion();
        return new URL("https", region.getServiceEndpoint(AmazonS3Client.S3_SERVICE_NAME),
                "/" + this.bucketName + "/" + this.objectName);
    } else {/*from w  w  w . ja  v  a  2s .  co m*/
        return super.getURL();
    }
}