software.amazon.awssdk.auth.credentials.StaticCredentialsProvider Java Examples

The following examples show how to use software.amazon.awssdk.auth.credentials.StaticCredentialsProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: S3Manager.java    From joyqueue with Apache License 2.0 9 votes vote down vote up
private String getS3Url(String objectKey) {
    AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey));
    S3Presigner preSigner = S3Presigner.builder()
            .credentialsProvider(credentialsProvider)
            .endpointOverride(URI.create(endpoint))
            .region(clientRegion).build();
    GetObjectRequest getObjectRequest = GetObjectRequest.builder()
            .bucket(bucketName)
            .key(objectKey)
            .build();
    GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder()
            .getObjectRequest(getObjectRequest).signatureDuration(Duration.ofDays(7)).build();
    PresignedGetObjectRequest presignedGetObjectRequest = preSigner.presignGetObject(getObjectPresignRequest);
    String url = presignedGetObjectRequest.url().toString();
    preSigner.close();
    return url;
}
 
Example #2
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 7 votes vote down vote up
@Test
public void regionalSettingEnabled_usesRegionalIadEndpoint() throws UnsupportedEncodingException {
    EnvironmentVariableHelper environmentVariableHelper = new EnvironmentVariableHelper();
    environmentVariableHelper.set(SdkSystemSetting.AWS_S3_US_EAST_1_REGIONAL_ENDPOINT.environmentVariable(), "regional");

    mockHttpClient.stubNextResponse(mockListObjectsResponse());

    S3Client s3Client = S3Client.builder()
            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
            .httpClient(mockHttpClient)
            .region(Region.US_EAST_1)
            .serviceConfiguration(S3Configuration.builder()
                    .pathStyleAccessEnabled(true)
                    .build())
            .build();
    try {
        s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build());
        assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.us-east-1.amazonaws.com");
    } finally {
        environmentVariableHelper.reset();
    }
}
 
Example #3
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void regionalSettingDisabled_usesGlobalEndpoint() throws UnsupportedEncodingException {
    EnvironmentVariableHelper environmentVariableHelper = new EnvironmentVariableHelper();
    environmentVariableHelper.set(SdkSystemSetting.AWS_S3_US_EAST_1_REGIONAL_ENDPOINT.environmentVariable(), "nonregional");

    mockHttpClient.stubNextResponse(mockListObjectsResponse());

    S3Client s3Client = S3Client.builder()
            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
            .httpClient(mockHttpClient)
            .region(Region.US_EAST_1)
            .serviceConfiguration(S3Configuration.builder()
                    .pathStyleAccessEnabled(true)
                    .build())
            .build();
    try {
        s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build());
        assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.amazonaws.com");
    } finally {
        environmentVariableHelper.reset();
    }
}
 
Example #4
Source File: EnhancedClientPutOverheadBenchmark.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Setup
public void setup(Blackhole bh) {
    ddb = DynamoDbClient.builder()
            .credentialsProvider(StaticCredentialsProvider.create(
                    AwsBasicCredentials.create("akid", "skid")))
            .httpClient(new MockHttpClient("{}", "{}"))
            .overrideConfiguration(c -> c.addExecutionInterceptor(new ExecutionInterceptor() {
                @Override
                public void afterUnmarshalling(Context.AfterUnmarshalling context,
                                               ExecutionAttributes executionAttributes) {
                    bh.consume(context);
                    bh.consume(executionAttributes);
                }
            }))
            .build();

    DynamoDbEnhancedClient ddbEnh = DynamoDbEnhancedClient.builder()
            .dynamoDbClient(ddb)
            .build();

    enhTable = ddbEnh.table(testItem.name(), testItem.tableSchema);
}
 
Example #5
Source File: SqsMessageQueueReceiverEndpointIntegrationTest.java    From synapse with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    new SqsClientHelper(asyncClient).createChannelIfNotExists(SQS_INTEGRATION_TEST_CHANNEL);

    AwsProperties awsProperties = new AwsProperties();
    awsProperties.setRegion(Region.EU_CENTRAL_1.id());

    delegateAsyncClient = SqsAsyncClient.builder()
            .credentialsProvider(StaticCredentialsProvider.create(
                    AwsBasicCredentials.create("foobar", "foobar")))
            .overrideConfiguration(ClientOverrideConfiguration.builder()
                    .apiCallAttemptTimeout(Duration.ofMillis(200))
                    .retryPolicy(new SqsAutoConfiguration(awsProperties)
                            .sqsRetryPolicy()).build())
            .endpointOverride(URI.create("http://localhost:8080/"))
            .build();
}
 
Example #6
Source File: AmazonWebServicesClientProxy.java    From cloudformation-cli-java-plugin with Apache License 2.0 6 votes vote down vote up
public AmazonWebServicesClientProxy(final boolean inHandshakeMode,
                                    final LoggerProxy loggerProxy,
                                    final Credentials credentials,
                                    final Supplier<Long> remainingTimeToExecute,
                                    final DelayFactory override) {
    this.inHandshakeMode = inHandshakeMode;
    this.loggerProxy = loggerProxy;
    this.remainingTimeInMillis = remainingTimeToExecute;

    BasicSessionCredentials basicSessionCredentials = new BasicSessionCredentials(credentials.getAccessKeyId(),
                                                                                  credentials.getSecretAccessKey(),
                                                                                  credentials.getSessionToken());
    this.v1CredentialsProvider = new AWSStaticCredentialsProvider(basicSessionCredentials);

    AwsSessionCredentials awsSessionCredentials = AwsSessionCredentials.create(credentials.getAccessKeyId(),
        credentials.getSecretAccessKey(), credentials.getSessionToken());
    this.v2CredentialsProvider = StaticCredentialsProvider.create(awsSessionCredentials);
    this.override = Objects.requireNonNull(override);
}
 
Example #7
Source File: DefaultPollyPresignerTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void presign_requestLevelCredentials_honored() {
    AwsCredentials requestCredentials = AwsBasicCredentials.create("akid2", "skid2");

    PollyPresigner presigner = DefaultPollyPresigner.builder()
            .region(Region.US_EAST_1)
            .credentialsProvider(credentialsProvider)
            .build();

    SynthesizeSpeechRequest synthesizeSpeechRequest = BASIC_SYNTHESIZE_SPEECH_REQUEST.toBuilder()
            .overrideConfiguration(AwsRequestOverrideConfiguration.builder()
                    .credentialsProvider(StaticCredentialsProvider.create(requestCredentials)).build())
            .build();

    SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder()
            .synthesizeSpeechRequest(synthesizeSpeechRequest)
            .signatureDuration(Duration.ofHours(3))
            .build();

    PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest);

    assertThat(presignedSynthesizeSpeechRequest.url().getQuery()).contains("X-Amz-Credential=akid2");
}
 
Example #8
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void regionalSettingUnset_usesGlobalEndpoint() throws UnsupportedEncodingException {
    mockHttpClient.stubNextResponse(mockListObjectsResponse());

    S3Client s3Client = S3Client.builder()
            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
            .httpClient(mockHttpClient)
            .region(Region.US_EAST_1)
            .serviceConfiguration(S3Configuration.builder()
                    .pathStyleAccessEnabled(true)
                    .build())
            .build();

    s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build());
    assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.amazonaws.com");
}
 
Example #9
Source File: QueryRequestTransformTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Before
public void setupClient() {
    client = ProtocolQueryClient.builder()
                                .credentialsProvider(StaticCredentialsProvider.create(
                                        AwsBasicCredentials.create("akid", "skid")))
                                .region(Region.US_EAST_1)
                                .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                .build();

    asyncClient = ProtocolQueryAsyncClient.builder()
                                          .credentialsProvider(StaticCredentialsProvider.create(
                                                  AwsBasicCredentials.create("akid", "skid")))
                                          .region(Region.US_EAST_1)
                                          .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                          .build();
}
 
Example #10
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void regionalSettingEnabledViaProfile_usesRegionalIadEndpoint() throws UnsupportedEncodingException {
    String profile =
        "[profile test]\n" +
        "s3_us_east_1_regional_endpoint = regional";

    ProfileFile profileFile = ProfileFile.builder()
                                         .content(new StringInputStream(profile))
                                         .type(ProfileFile.Type.CONFIGURATION)
                                         .build();

    mockHttpClient.stubNextResponse(mockListObjectsResponse());

    S3Client s3Client = S3Client.builder()
                                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                .httpClient(mockHttpClient)
                                .region(Region.US_EAST_1)
                                .overrideConfiguration(c -> c.defaultProfileFile(profileFile)
                                                             .defaultProfileName("test"))
                                .serviceConfiguration(c -> c.pathStyleAccessEnabled(true))
                                .build();

    s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build());
    assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.us-east-1.amazonaws.com");
}
 
Example #11
Source File: Aws2ITest.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
private static DynamoDbClient buildClient() {
  final AwsSessionCredentials awsCreds = AwsSessionCredentials.create("access_key_id", "secret_key_id", "session_token");
  return DynamoDbClient
    .builder()
    .endpointOverride(URI.create("http://localhost:8000"))
    .region(Region.US_WEST_2)
    .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
    .overrideConfiguration(ClientOverrideConfiguration.builder().apiCallTimeout(Duration.ofSeconds(1)).build())
    .build();

  // final AwsClientBuilder.EndpointConfiguration endpointConfiguration = new
  // AwsClientBuilder.EndpointConfiguration(
  // "http://localhost:8000", "us-west-2");
  // final BasicAWSCredentials awsCreds = new
  // BasicAWSCredentials("access_key_id", "secret_key_id");
  // final AmazonDynamoDBClientBuilder builder = AmazonDynamoDBClientBuilder
  // .standard()
  // .withEndpointConfiguration(endpointConfiguration)
  // .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
  // .withClientConfiguration(new
  // ClientConfiguration().withConnectionTimeout(1));
  //
  // return builder.build();
}
 
Example #12
Source File: PaginatorInUserAgentTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    dynamoDbClient = DynamoDbClient.builder()
                                   .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("test",
                                                                                                                    "test")))
                                   .region(Region.US_WEST_2).endpointOverride(URI.create("http://localhost:" + mockServer
            .port()))
                                   .build();

    dynamoDbAsyncClient = DynamoDbAsyncClient.builder()
                                             .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials
                                                                                                       .create("test",
                                                                                                                              "test")))
                                             .region(Region.US_WEST_2).endpointOverride(URI.create("http://localhost:" +
                                                                                                   mockServer.port()))
                                             .build();
}
 
Example #13
Source File: AwsJsonRetryTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupClient() {
    client = ProtocolJsonRpcClient.builder()
                                  .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                  .region(Region.US_EAST_1)
                                  .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                  .build();
}
 
Example #14
Source File: ExecutionInterceptorTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private <T extends AwsClientBuilder<?, U>, U> U initializeAndBuild(T builder, ExecutionInterceptor interceptor) {
    return builder.region(Region.US_WEST_1)
                  .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                  .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                  .overrideConfiguration(ClientOverrideConfiguration.builder()
                                                                    .addExecutionInterceptor(interceptor)
                                                                    .build())
                  .build();
}
 
Example #15
Source File: ClockSkewAdjustmentTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private ProtocolJsonRpcClient createClient(int retryCount) {
    return ProtocolJsonRpcClient.builder()
                                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                .region(Region.US_EAST_1)
                                .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                .overrideConfiguration(c -> c.retryPolicy(r -> r.numRetries(retryCount)))
                                .build();
}
 
Example #16
Source File: ClockSkewAdjustmentTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private ProtocolJsonRpcAsyncClient createAsyncClient(int retryCount) {
    return ProtocolJsonRpcAsyncClient.builder()
                                     .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                     .region(Region.US_EAST_1)
                                     .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                     .overrideConfiguration(c -> c.retryPolicy(r -> r.numRetries(retryCount)))
                                     .build();
}
 
Example #17
Source File: QueryMetadataTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupClient() {
    client = ProtocolQueryClient.builder()
                                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                .region(Region.US_EAST_1)
                                .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                .build();

    asyncClient = ProtocolQueryAsyncClient.builder()
                                          .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                          .region(Region.US_EAST_1)
                                          .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                          .build();
}
 
Example #18
Source File: SyncClientConnectionTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupClient() {
    mockHttpClient = new MockHttpClient();
    client = ProtocolRestJsonClient.builder()
                                   .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid",
                                                                                                                   "skid")))
                                   .region(Region.US_EAST_1)
                                   .httpClient(mockHttpClient)
                                   .build();
}
 
Example #19
Source File: AsyncAwsJsonRetryTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void retryPolicyNone_shouldNotRetry() {
    stubFor(post(urlEqualTo(PATH))
                .inScenario("retry at 500")
                .whenScenarioStateIs(Scenario.STARTED)
                .willSetStateTo("first attempt")
                .willReturn(aResponse()
                                .withStatus(500)));

    stubFor(post(urlEqualTo(PATH))
                .inScenario("retry at 500")
                .whenScenarioStateIs("first attempt")
                .willSetStateTo("second attempt")
                .willReturn(aResponse()
                                .withStatus(200)
                                .withBody(JSON_BODY)));

    ProtocolJsonRpcAsyncClient clientWithNoRetry =
        ProtocolJsonRpcAsyncClient.builder()
                                  .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid",
                                                                                                                   "skid")))
                                  .region(Region.US_EAST_1)
                                  .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                  .overrideConfiguration(c -> c.retryPolicy(RetryPolicy.none()))
                                  .build();

    assertThatThrownBy(() -> clientWithNoRetry.allTypes(AllTypesRequest.builder().build()).join())
        .hasCauseInstanceOf(ProtocolJsonRpcException.class);
}
 
Example #20
Source File: AsyncResponseTransformerTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupClient() {
    jsonClient = ProtocolRestJsonAsyncClient.builder()
                                            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                            .region(Region.US_EAST_1)
                                            .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                            .build();
    xmlClient = ProtocolQueryAsyncClient.builder()
                                        .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(
                                            "akid", "skid")))
                                        .region(Region.US_EAST_1)
                                        .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                        .build();
}
 
Example #21
Source File: InspectorErrorUnmarshallingTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    StaticCredentialsProvider credsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"));
    inspector = InspectorClient.builder()
                               .credentialsProvider(credsProvider)
                               .region(Region.US_EAST_1)
                               .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                               .build();
}
 
Example #22
Source File: UploadArchiveHeaderTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    glacier = GlacierClient.builder()
            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
            .region(Region.US_WEST_2).endpointOverride(URI.create(getEndpoint()))
            .build();
    request = UploadArchiveRequest.builder().vaultName("test").build();
}
 
Example #23
Source File: CompleteMultipartUploadFunctionalTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private S3AsyncClientBuilder getAsyncClientBuilder() {
    return S3AsyncClient.builder()
                        .region(Region.US_EAST_1)
                        .endpointOverride(HTTP_LOCALHOST_URI)
                        .credentialsProvider(
                            StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret")));

}
 
Example #24
Source File: CompleteMultipartUploadFunctionalTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private S3ClientBuilder getSyncClientBuilder() {

        return S3Client.builder()
                       .region(Region.US_EAST_1)
                       .endpointOverride(HTTP_LOCALHOST_URI)
                       .credentialsProvider(
                           StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret")));
    }
 
Example #25
Source File: GetBucketPolicyFunctionalTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private S3AsyncClientBuilder getAsyncClientBuilder() {
    return S3AsyncClient.builder()
                        .region(Region.US_EAST_1)
                        .endpointOverride(HTTP_LOCALHOST_URI)
                        .credentialsProvider(
                            StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret")));

}
 
Example #26
Source File: GetBucketPolicyFunctionalTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private S3ClientBuilder getSyncClientBuilder() {

        return S3Client.builder()
                       .region(Region.US_EAST_1)
                       .endpointOverride(HTTP_LOCALHOST_URI)
                       .credentialsProvider(
                           StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret")));
    }
 
Example #27
Source File: MultipartUploadTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    s3Client = S3Client.builder()
                       .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                       .region(Region.US_WEST_2).endpointOverride(URI.create("http://localhost:" + mockServer.port()))
                       .serviceConfiguration(S3Configuration.builder().checksumValidationEnabled(false).build())
                       .build();

    s3AsyncClient = S3AsyncClient.builder()
                                 .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid",
                                                                                                                  "skid")))
                                 .region(Region.US_WEST_2).endpointOverride(URI.create("http://localhost:" + mockServer.port()))
                                 .serviceConfiguration(S3Configuration.builder().checksumValidationEnabled(false).build())
                                 .build();
}
 
Example #28
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * @return Client builder instance preconfigured with credentials and region using the {@link #mockHttpClient} for transport
 * and {@link #mockSigner} for signing. Using actual AwsS3V4Signer results in NPE as the execution goes into payload signing
 * due to "http" protocol and input stream is not mark supported.
 */
private S3ClientBuilder clientBuilderWithMockSigner() {
    return S3Client.builder()
                   .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                   .region(Region.AP_SOUTH_1)
                   .overrideConfiguration(ClientOverrideConfiguration.builder()
                                                                     .putAdvancedOption(SdkAdvancedClientOption.SIGNER,
                                                                                        mockSigner)
                                                                     .build())
                   .httpClient(mockHttpClient);
}
 
Example #29
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * @return Client builder instance preconfigured with credentials and region using the {@link #mockHttpClient} for transport.
 */
private S3ClientBuilder clientBuilder() {
    return S3Client.builder()
                   .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                   .region(Region.AP_SOUTH_1)
                   .httpClient(mockHttpClient);
}
 
Example #30
Source File: AclTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    URI endpoint = URI.create("http://localhost:" + mockServer.port());
    s3Client = S3Client.builder()
                       .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                       .region(Region.US_WEST_2)
                       .endpointOverride(endpoint)
                       .build();
}