Skip to content

Commit 84d7b62

Browse files
committed
Work with assumed roles on ec2
1 parent 781b4dc commit 84d7b62

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/redis_release/state_manager.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def s3_client(self) -> Optional[boto3.client]:
7474
region_name=self.aws_region,
7575
)
7676
else:
77-
logger.error("AWS credentials not found")
78-
logger.warning(
79-
"Set AWS_PROFILE or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY environment variables"
77+
# Fall back to default credential chain (includes EC2 instance profile, ECS task role, etc.)
78+
logger.info(
79+
"Using AWS default credential chain (EC2 instance profile, ECS task role, etc.)"
8080
)
81-
raise NoCredentialsError()
81+
self._s3_client = boto3.client("s3", region_name=self.aws_region)
8282

8383
# Test connection
8484
self._s3_client.head_bucket(Bucket=self.bucket_name)
@@ -92,6 +92,11 @@ def s3_client(self) -> Optional[boto3.client]:
9292
logger.error(f"S3 error: {e}")
9393
raise
9494
except NoCredentialsError:
95+
logger.error("AWS credentials not found")
96+
logger.warning(
97+
"Set AWS_PROFILE or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY environment variables, "
98+
"or run on EC2 instance with IAM role"
99+
)
95100
raise
96101
except Exception as e:
97102
logger.error(f"AWS authentication error: {e}")

0 commit comments

Comments
 (0)