package com.eactive.eai.rms.ext.kakaocard.config;

import org.apache.log4j.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.Profile;
import software.amazon.awssdk.services.s3.S3Client;

@Configuration
public class AWSConfig {
   
   private static final Logger logger = Logger.getLogger(AWSConfig.class);
   
   @Bean(name = "s3Client")
   @Profile("aws")
   public S3Client s3Client() {
      
      try {
         return S3Client.builder()
//               .credentialsProvider(DefaultCredentialsProvider.create()) // KakaoCard Config 설정 필요 없음.
               .build();
      } catch (Exception e) {
         logger.warn("S3Client Bean Not Available.", e);
         throw new RuntimeException(e);
      }

   }

   @Bean(name = "s3Client")
   @Profile("!aws")
   public S3Client mockS3Client() {
      return new MockS3Client();
   }

}

class MockS3Client implements S3Client {

   @Override
   public String serviceName() {
      return null;
   }

   @Override
   public void close() {
      
   }
   
}