-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/s3 credentials on local #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
환경변수가 아니라 EC2 인스턴스 IAM Role로 S3에 접근하기 때문. 환경변수는 local에서만 사용됨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses an issue where S3 connections were failing in dev/prod environments because the credential check logic was incorrectly skipping S3 initialization when AWS credentials were not present as environment variables. In these environments, IAM roles are used instead of explicit credentials.
Key changes:
- Modified credential validation to only require AWS credentials (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) in the local environment, while allowing dev/prod environments to rely on IAM roles - Refactored duplicate S3 enablement checks by introducing a reusable
checkS3Enabledhelper method that provides consistent logging across all operations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/file/file.service.ts
Outdated
|
|
||
| constructor() { | ||
| // AWS 자격 증명이 있을 때만 S3Client 초기화 | ||
| const isLocal = process.env.NODE_ENV === 'local'; |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If NODE_ENV is undefined or null, the isLocal check will be false, causing the code to skip credential validation and attempt to use IAM roles. This could lead to unexpected behavior in environments where NODE_ENV is not set. Consider handling the undefined/null case explicitly or defaulting to requiring credentials for safety when the environment is not explicitly specified.
| const isLocal = process.env.NODE_ENV === 'local'; | |
| const isLocal = !process.env.NODE_ENV || process.env.NODE_ENV === 'local'; |
배경
#193 의 연장 작업.
dev/prod 환경에서는 S3 credentials(
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY)를 사용하지 않아서 환경변수가 없음. 그런데 기존 로직에서는 해당 환경변수 유무로 S3 연결 체크를 했기 때문에 dev 환경에서 S3 연결이 생략되어 데이터를 가져오지 못하는 문제 발생작업내용
S3 credentials는 local 환경일 때만 체크하도록 설정
기존
dev 환경일 때 S3 연결이 생략되어, S3에 있는 설정값을 가져오지 못했음

작업 후
잘 가져옴
