Skip to content

Commit 0f07dd8

Browse files
committed
moved timeout to env var
1 parent 6bea3b7 commit 0f07dd8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

prometrix/connect/aws_connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
SA_TOKEN_PATH = os.environ.get("SA_TOKEN_PATH", "/var/run/secrets/eks.amazonaws.com/serviceaccount/token")
1717
AWS_ASSUME_ROLE = os.environ.get("AWS_ASSUME_ROLE")
18+
AWS_REFRESH_CREDS_SEC = int(os.environ.get("AWS_REFRESH_CREDS_SEC", "900")) # 15 minutes
1819

1920
class AWSPrometheusConnect(CustomPrometheusConnect):
2021
def __init__(
@@ -99,7 +100,7 @@ def _assume_role(self, role_arn: str) -> None:
99100
def _build_auth(self) -> SigV4Auth:
100101
"""Builds fresh SigV4 auth with current credentials (handles rotation)."""
101102
try:
102-
if self._last_init_at is None or (datetime.utcnow() - self._last_init_at).total_seconds() >= 900:
103+
if self._last_init_at is None or (datetime.utcnow() - self._last_init_at).total_seconds() >= AWS_REFRESH_CREDS_SEC:
103104
logging.debug("Fifteen minutes passed; re-initializing AWS credentials")
104105
self.init_credentials()
105106
except Exception:

0 commit comments

Comments
 (0)