package com.sonic.shark.config;

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.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;

/**
 * code
 **/
@Configuration
public class AwsS3Config {

    @Value("${aws.s3.fileOpt.accessKeyId}")
    private String awsId;
    @Value("${aws.s3.fileOpt.secretAccessKey}")
    private String awsKey;

    @Bean
    public S3Client s3client() {
        AwsBasicCredentials awsCreds = AwsBasicCredentials.create(awsId, awsKey);
        S3Client s3Client = S3Client.builder()
                .region(Region.US_WEST_2)
                .credentialsProvider(StaticCredentialsProvider.create(awsCreds)).build();
        return s3Client;
    }
}
