somoly.tistory.com

로컬 환경에서는 access key 와 secret key 를 발급 받아 사용을하고, ec2 에서는 iam 인증 설정을 통해 aws 자원에 접근하는 전략을 사용하고 있습니다.

따라서 환경별로 인증방식을 달리 하기 위해 아래와 같이 설정을 사용하고 있습니다.

 

<kotlin />
// application.properties // app.aws.auth.access-key-id=iam // app.aws.auth.secret-access-key=iam @ConfigurationProperties(prefix = "app.aws.auth") data class AwsCredentialsProperties( val accessKeyId: String = "iam", val secretAccessKey: String = "iam", ) @EnableConfigurationProperties(AwsCredentialsProperties::class) @Configuration(proxyBeanMethods = false) class AwsCredentialsProviderConfig { @Profile("local") @ConditionalOnMissingBean @Bean fun awsStaticCredentialsProvider(properties: AwsCredentialsProperties): AwsCredentialsProvider { return StaticCredentialsProvider.create(AwsBasicCredentials.create(properties.accessKeyId, properties.secretAccessKey)) } @Profile("!local") @ConditionalOnMissingBean @Bean fun awsInstanceProfileCredentialsProvider(): AwsCredentialsProvider { return InstanceProfileCredentialsProvider.create() } }

 

 

 

'SpringBoot' 카테고리의 다른 글

Kotlin Simple Version Compare  (0) 2023.03.21
Spring 6 의 HTTP Interface  (0) 2023.03.14
Retrying Feign Calls  (0) 2023.03.14
RedisTemplate 과 Json Serializer 설정  (0) 2019.07.09
MongoDB _class 필드 제거하기  (0) 2019.07.09
profile

somoly.tistory.com

@RxCats

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!