Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data changes #12

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DataCompareController(IDataPullerService dataPullerService) {
@GetMapping(path = "/api/data-compare")
public ResponseEntity<String> dataSyncTotalRecords(
@RequestHeader(name = "batchLimit", defaultValue = "1000") String batchLimit,
@RequestParam(name = "runNowMode", defaultValue = "false") boolean runNowMode) throws DataCompareException {
@RequestHeader(name = "runNowMode", defaultValue = "false") boolean runNowMode) throws DataCompareException {

if (isInteger(batchLimit)) {
dataPullerService.pullingData(Integer.parseInt(batchLimit), runNowMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
Expand Down Expand Up @@ -39,10 +40,17 @@ public S3DataService(
@Value("${aws.auth.static.access_key}") String accessKey,
@Value("${aws.auth.static.token}") String token,
@Value("${aws.s3.region}") String region,
@Value("${aws.auth.profile.profile_name}") String profile
@Value("${aws.auth.profile.profile_name}") String profile,
@Value("${aws.auth.iam.enabled}") boolean iamEnable
) throws DataCompareException
{
if (!keyId.isEmpty() && !accessKey.isEmpty() && !token.isEmpty()) {
if (iamEnable) {
this.s3Client = S3Client.builder()
.region(Region.of(region))
.credentialsProvider(DefaultCredentialsProvider.create()) // Automatically retrieves IAM role credentials
.build();
}
else if (!keyId.isEmpty() && !accessKey.isEmpty() && !token.isEmpty()) {
this.s3Client = S3Client.builder()
.region(Region.of(region))
.credentialsProvider(StaticCredentialsProvider.create(
Expand Down
2 changes: 2 additions & 0 deletions DataCompareAPIs/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ aws:
token: ${AWS_TOKEN:NA}
profile:
profile_name: ${AWS_PROFILE:NA}
iam:
enabled: ${AWS_IAM:false}
s3:
bucket-name: ${S3_BUCKET_NAME:NA}
region: ${S3_REGION:NA}
Expand Down
Loading