Search in sources :

Example 1 with Region

use of software.amazon.awssdk.regions.Region in project janusgraph by JanusGraph.

the class AwsCodePipelinesCi method run.

private void run() throws IOException {
    final File file = new File(getOptionValue(PIPELINES_JSON_OPTION));
    final Region region = Region.of(getOptionValue(REGION_OPTION));
    final AwsCredentialsProvider provider = ProfileCredentialsProvider.builder().profileName(getOptionValue(PROFILE_OPTION)).build();
    final ClientHttpConfiguration http = ClientHttpConfiguration.builder().httpClient(// consider netty some other time
    ApacheSdkHttpClientFactory.builder().socketTimeout(Duration.ofSeconds(10)).connectionTimeout(Duration.ofMillis(750)).build().createHttpClient()).build();
    final AwsCodePipelinesLogic.AwsCodePipelinesLogicBuilder builder = AwsCodePipelinesLogic.builder().githubToken(getOptionValue(GITHUB_TOKEN_OPTION)).githubOwner(getOptionValue(GITHUB_OWNER_OPTION)).githubRepo(getOptionValue(GITHUB_REPO_OPTION)).githubBranch(getOptionValue(GITHUB_BRANCH_OPTION)).codeBuildServiceRoleArn(getOptionValue(CODE_BUILD_SERVICE_ROLE_ARN_OPTION)).codePipelineRoleArn(getOptionValue(CODEPIPELINE_ROLE_ARN_OPTION)).s3Bucket(getOptionValue(BUCKET_OPTION)).s3BucketLocationConstraint(BucketLocationConstraint.fromValue(region.value())).s3(S3Client.builder().httpConfiguration(http).region(region).credentialsProvider(provider).build()).codeBuild(CodeBuildClient.builder().httpConfiguration(http).region(region).credentialsProvider(provider).build()).codePipeline(CodePipelineClient.builder().httpConfiguration(http).region(region).credentialsProvider(provider).build());
    final Tag timeTag = Tag.builder().key("date").value(Long.toString(System.currentTimeMillis())).build();
    final PipelineDefinitions definitions = new ObjectMapper(new YAMLFactory()).readValue(file, PipelineDefinitions.class);
    definitions.getPipelines().stream().map(def -> builder.pipelineName(def.getName()).sourceOutputArtifactName(def.getName() + "Source").parallelBuildActions(def.getParallelBuildActions()).defaultComputeImage(definitions.getDefaultComputeImage()).defaultComputeType(definitions.getDefaultComputeType()).defaultPrivilegedMode(definitions.isDefaultPrivilegedMode()).tags(ImmutableList.of(Tag.builder().key("project").value(def.getName()).build(), timeTag)).build()).forEach(AwsCodePipelinesLogic::run);
}
Also used : IAMException(software.amazon.awssdk.services.iam.model.IAMException) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Options(org.apache.commons.cli.Options) PipelineDefinitions(org.janusgraph.codepipelines.model.PipelineDefinitions) CodeBuildClient(software.amazon.awssdk.services.codebuild.CodeBuildClient) BucketLocationConstraint(software.amazon.awssdk.services.s3.model.BucketLocationConstraint) DefaultParser(org.apache.commons.cli.DefaultParser) ImmutableList(com.google.common.collect.ImmutableList) ApacheSdkHttpClientFactory(software.amazon.awssdk.http.apache.ApacheSdkHttpClientFactory) Duration(java.time.Duration) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) CommandLine(org.apache.commons.cli.CommandLine) Region(software.amazon.awssdk.regions.Region) Option(org.apache.commons.cli.Option) ClientHttpConfiguration(software.amazon.awssdk.client.builder.ClientHttpConfiguration) S3Client(software.amazon.awssdk.services.s3.S3Client) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) CodePipelineClient(software.amazon.awssdk.services.codepipeline.CodePipelineClient) File(java.io.File) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ParseException(org.apache.commons.cli.ParseException) AwsCredentialsProvider(software.amazon.awssdk.auth.AwsCredentialsProvider) ProfileCredentialsProvider(software.amazon.awssdk.auth.ProfileCredentialsProvider) Tag(software.amazon.awssdk.services.s3.model.Tag) ClientHttpConfiguration(software.amazon.awssdk.client.builder.ClientHttpConfiguration) AwsCredentialsProvider(software.amazon.awssdk.auth.AwsCredentialsProvider) Region(software.amazon.awssdk.regions.Region) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) PipelineDefinitions(org.janusgraph.codepipelines.model.PipelineDefinitions) Tag(software.amazon.awssdk.services.s3.model.Tag) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with Region

use of software.amazon.awssdk.regions.Region in project flink by apache.

the class AWSAsyncSinkUtilTest method testCreateKinesisAsyncClient.

@Test
public void testCreateKinesisAsyncClient() {
    Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
    MockAsyncClientBuilder builder = mockKinesisAsyncClientBuilder();
    ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder().build();
    SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder().build();
    AWSAsyncSinkUtil.createAwsAsyncClient(properties, builder, httpClient, clientOverrideConfiguration);
    verify(builder).overrideConfiguration(clientOverrideConfiguration);
    verify(builder).httpClient(httpClient);
    verify(builder).region(Region.of("eu-west-2"));
    verify(builder).credentialsProvider(argThat(cp -> cp instanceof DefaultCredentialsProvider));
    verify(builder, never()).endpointOverride(any());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) AwsAsyncClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) SdkAdvancedClientOption(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) Duration(java.time.Duration) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) URI(java.net.URI) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Region(software.amazon.awssdk.regions.Region) ClientAsyncConfiguration(software.amazon.awssdk.core.client.config.ClientAsyncConfiguration) Properties(java.util.Properties) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) Mockito.verify(org.mockito.Mockito.verify) AWS_REGION(org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_REGION) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) Mockito.never(org.mockito.Mockito.never) SdkClient(software.amazon.awssdk.core.SdkClient) AWS_ENDPOINT(org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_ENDPOINT) AWSAsyncSinkUtil.formatFlinkUserAgentPrefix(org.apache.flink.connector.aws.util.AWSAsyncSinkUtil.formatFlinkUserAgentPrefix) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) Mockito.mock(org.mockito.Mockito.mock) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) DefaultCredentialsProvider(software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with Region

use of software.amazon.awssdk.regions.Region in project beam by apache.

the class SqsIOWriteTest method testBuildWithCredentialsProviderAndRegionAndEndpoint.

@Test
public void testBuildWithCredentialsProviderAndRegionAndEndpoint() {
    Region region = Region.US_EAST_1;
    AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create();
    URI endpoint = URI.create("localhost:9999");
    Write write = SqsIO.write().withSqsClientProvider(credentialsProvider, region.id(), endpoint);
    assertThat(write.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, endpoint));
}
Also used : Write(org.apache.beam.sdk.io.aws2.sqs.SqsIO.Write) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Region(software.amazon.awssdk.regions.Region) URI(java.net.URI) Test(org.junit.Test)

Example 4 with Region

use of software.amazon.awssdk.regions.Region in project beam by apache.

the class ClientConfigurationTest method testSerialization.

@Test
public void testSerialization() {
    AwsCredentialsProvider credentials = StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"));
    ClientConfiguration config = ClientConfiguration.builder().credentialsProvider(credentials).region(Region.US_WEST_1).endpoint(URI.create("https://localhost")).retry(b -> b.numRetries(3)).build();
    byte[] serializedBytes = serializeToByteArray(config);
    ClientConfiguration deserializedConfig = (ClientConfiguration) deserializeFromByteArray(serializedBytes, "ClientConfiguration");
    assertThat(deserializedConfig).isEqualTo(config);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) SerializableUtils.deserializeFromByteArray(org.apache.beam.sdk.util.SerializableUtils.deserializeFromByteArray) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SerializableUtils.serializeToByteArray(org.apache.beam.sdk.util.SerializableUtils.serializeToByteArray) Test(org.junit.Test) URI(java.net.URI) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) Region(software.amazon.awssdk.regions.Region) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Test(org.junit.Test)

Example 5 with Region

use of software.amazon.awssdk.regions.Region in project beam by apache.

the class DynamoDBIOWriteTest method testBuildWithCredentialsProviderAndRegionAndEndpoint.

@Test
public void testBuildWithCredentialsProviderAndRegionAndEndpoint() {
    Region region = Region.US_EAST_1;
    AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create();
    URI endpoint = URI.create("localhost:9999");
    Write<Object> write = DynamoDBIO.write().withDynamoDbClientProvider(credentialsProvider, region.id(), endpoint);
    assertThat(write.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, endpoint));
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Region(software.amazon.awssdk.regions.Region) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Region (software.amazon.awssdk.regions.Region)534 S3Client (software.amazon.awssdk.services.s3.S3Client)43 RekognitionClient (software.amazon.awssdk.services.rekognition.RekognitionClient)32 DynamoDbClient (software.amazon.awssdk.services.dynamodb.DynamoDbClient)31 IamClient (software.amazon.awssdk.services.iam.IamClient)23 PersonalizeClient (software.amazon.awssdk.services.personalize.PersonalizeClient)22 Ec2Client (software.amazon.awssdk.services.ec2.Ec2Client)20 Test (org.junit.Test)17 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)15 KmsClient (software.amazon.awssdk.services.kms.KmsClient)15 URI (java.net.URI)13 CodeCommitClient (software.amazon.awssdk.services.codecommit.CodeCommitClient)13 GlueClient (software.amazon.awssdk.services.glue.GlueClient)12 Properties (java.util.Properties)11 DynamoDbEnhancedClient (software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient)11 SesClient (software.amazon.awssdk.services.ses.SesClient)11 SdkBytes (software.amazon.awssdk.core.SdkBytes)9 Route53Client (software.amazon.awssdk.services.route53.Route53Client)9 CloudTrailClient (software.amazon.awssdk.services.cloudtrail.CloudTrailClient)8 CloudWatchClient (software.amazon.awssdk.services.cloudwatch.CloudWatchClient)8