profiles 를 이용한 aws iam 과 secret key 기반 인증 설정

2023. 6. 26. 22:55·SpringBoot

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

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

 

// 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
'SpringBoot' 카테고리의 다른 글
  • Kotlin Simple Version Compare
  • Spring 6 의 HTTP Interface
  • Retrying Feign Calls
  • RedisTemplate 과 Json Serializer 설정
somoly
somoly
About me.
  • somoly
    somoly.tistory.com
    somoly
  • 전체
    오늘
    어제
    • 전체 (55)
      • SpringBoot (8)
      • Kotlin (5)
      • Javascript (4)
      • 백엔드 (6)
      • Linux (25)
      • Windows (1)
      • IT (2)
      • FF14 (1)
      • 애니 (1)
      • Figure (1)
      • 회사생활 (1)
  • 블로그 메뉴

    • HOME
    • TAGS
    • MEDIA
    • LOCATION
    • GUESTBOOK
    • ADMIN
    • WRITE
  • 링크

    • [FF14] 5.0 (71-80) 제작 레벨링 매크로
    • [FF14] 갈론드벨
    • [FF14] FFLogs
    • [FF14] Ariyala 장비 시뮬레이터
    • [FF14] 낚시 도우미
    • [FF14] 인테리어 정보
    • [FF14] 의상 코디 정보
  • 공지사항

  • 인기 글

  • 태그

    83인치
    dynamodb local
    동영상
    utf-8
    Spring
    HTTP
    설치
    interactive table
    P2P
    ubuntu
    jvminline
    30일전
    Kotlin
    부팅
    77인치
    bcmod
    VirtualBox
    springboot
    accesskey
    우분투
    exchage method
    tabulator
    javascript
    피규어
    versioncomapre
    종료
    linux
    리눅스
    최후의 재림
    string methods
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
somoly
profiles 를 이용한 aws iam 과 secret key 기반 인증 설정
상단으로

티스토리툴바