Skip to content

Commit

Permalink
Use S3CrtAsyncClient as recommended by AWS
Browse files Browse the repository at this point in the history
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/crt-based-s3-client.html

Removed feature flag as the old environments where Crt didn't work are
no longer in use.
  • Loading branch information
rce committed Dec 16, 2024
1 parent cc3ae39 commit 7d55351
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class LampiConfiguration {
private String lampiRoleArn;
@Value("${kayttooikeus.tasks.export.lampi-external-id}")
private String lampiExternalId;
@Value("${kayttooikeus.tasks.export.use-crt-client:false}")
private boolean useCrtClient;

@Bean
StsAssumeRoleCredentialsProvider lampiCredentialsProvider(AwsCredentialsProvider opinpolkuCredentialsProvider) {
Expand All @@ -40,16 +38,9 @@ StsAssumeRoleCredentialsProvider lampiCredentialsProvider(AwsCredentialsProvider

@Bean
S3AsyncClient lampiS3Client(StsAssumeRoleCredentialsProvider lampiCredentialsProvider) {
if (!useCrtClient) {
return S3AsyncClient.builder()
.credentialsProvider(lampiCredentialsProvider)
.region(REGION)
.build();
} else {
return S3AsyncClient.crtBuilder()
.credentialsProvider(lampiCredentialsProvider)
.region(REGION)
.build();
}
return S3AsyncClient.crtBuilder()
.credentialsProvider(lampiCredentialsProvider)
.region(REGION)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fi.vm.sade.kayttooikeus.export;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
Expand All @@ -12,26 +11,16 @@
public class OpintopolkuAwsClients {
static final Region REGION = Region.EU_WEST_1;

@Value("${kayttooikeus.tasks.export.use-crt-client:false}")
private boolean useCrtClient;

@Bean
AwsCredentialsProvider opintopolkuCredentialsProvider() {
return DefaultCredentialsProvider.create();
}

@Bean
S3AsyncClient opintopolkuS3Client(AwsCredentialsProvider opintopolkuCredentialsProvider) {
if (!useCrtClient) {
return S3AsyncClient.builder()
.credentialsProvider(opintopolkuCredentialsProvider)
.region(REGION)
.build();
} else {
return S3AsyncClient.crtBuilder()
.credentialsProvider(opintopolkuCredentialsProvider)
.region(REGION)
.build();
}
return S3AsyncClient.crtBuilder()
.credentialsProvider(opintopolkuCredentialsProvider)
.region(REGION)
.build();
}
}
1 change: 0 additions & 1 deletion kayttooikeus-service/src/main/resources/config/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ server.port: 8080

kayttooikeus.tasks.export.enabled: true
kayttooikeus.tasks.export.bucket-name: ${export_bucket_name}
kayttooikeus.tasks.export.use-crt-client: true
kayttooikeus.tasks.export.copy-to-lampi: true
kayttooikeus.tasks.export.lampi-bucket-name: oph-lampi-dev
kayttooikeus.tasks.export.lampi-role-arn: ${ssm_lampi_role_arn}
Expand Down
1 change: 0 additions & 1 deletion kayttooikeus-service/src/main/resources/config/hahtuva.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ server.port: 8080

kayttooikeus.tasks.export.enabled: true
kayttooikeus.tasks.export.bucket-name: ${export_bucket_name}
kayttooikeus.tasks.export.use-crt-client: true
kayttooikeus.tasks.export.copy-to-lampi: false
kayttooikeus.tasks.export.lampi-bucket-name: none
kayttooikeus.tasks.export.lampi-role-arn: none
Expand Down
1 change: 0 additions & 1 deletion kayttooikeus-service/src/main/resources/config/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ server.port: 8080

kayttooikeus.tasks.export.enabled: true
kayttooikeus.tasks.export.bucket-name: ${export_bucket_name}
kayttooikeus.tasks.export.use-crt-client: true
kayttooikeus.tasks.export.copy-to-lampi: true
kayttooikeus.tasks.export.lampi-bucket-name: oph-lampi-prod
kayttooikeus.tasks.export.lampi-role-arn: ${ssm_lampi_role_arn}
Expand Down
1 change: 0 additions & 1 deletion kayttooikeus-service/src/main/resources/config/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ server.port: 8080

kayttooikeus.tasks.export.enabled: true
kayttooikeus.tasks.export.bucket-name: ${export_bucket_name}
kayttooikeus.tasks.export.use-crt-client: true
kayttooikeus.tasks.export.copy-to-lampi: true
kayttooikeus.tasks.export.lampi-bucket-name: oph-lampi-qa
kayttooikeus.tasks.export.lampi-role-arn: ${ssm_lampi_role_arn}
Expand Down

0 comments on commit 7d55351

Please sign in to comment.