[Spring boot] ec2 배포중에 난 Fail fast is set and there was an error reading configuration from AWS Secrets Manager

Chae Eun Kim·2023년 3월 21일
0

spring boot

목록 보기
5/5
  • 문제 상황 : 급하게 spring boot 프로젝트를 EC2에 올려서 jar파일로 빌드하고, 실행시키려고 하는데, 아래와 같이 AWS Secrets Manager confiure가 안된다는 에러가 발생함. AWS credentials를 load할 수 없다고 한다.

cat nohup.out 명령어로 확인한 에러 로그

2023-03-21 08:22:13.670 ERROR 4640 --- [           main] s.AwsSecretsManagerPropertySourceLocator : Fail fast is set and there was an error reading configuration from AWS Secrets Manager:
Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path., 
어쩌구 저쩌구
2023-03-21 08:22:13.761 ERROR 4640 --- [           main] o.s.boot.SpringApplication               : Application run failed

com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path.,



  • 원인: 원래 application.yml 파일로 aws secret managers에 환경변수를 등록하고 읽어오도록 스크립트가 작성되어있던 프로젝트였는데, CI/CD가 안먹혀서 급하게 EC2에만 배포한거라 이 스크립트가 실행이 안된다는 것을 깜박하고 있었다.
  • 해결: 그래서 로컬환경이라 생각하고 로컬에서 작업할 때처럼 AWS CLI를 설치해서 aws configure로 키 등록과정을 함으로써 해결함.
  1. aws cli 설치 : sudo apt install awscli
  2. aws configure 명령어 입력 후
    계속 쓰고있던 IAM 사용자의 access key와 secret key 입력해준 후, region은 ap-northeast-2 입력함
  3. 다시 build 파일 실행함 nohup java -jar my-0.0.1-SNAPSHOT.jar &

cat nohup.out 로 잘실행되었나 확인했더니, tomcat 8080포트가 잘 뜨는 것을 확인함.

0개의 댓글