Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 07d8420

Browse files
author
Nish Bhat
committed
[SEC-102] show warning if clrenv fails to connect to AWS SSM
1 parent b77291c commit 07d8420

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

clrenv/lazy_env.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from __future__ import print_function
22
from builtins import object
3-
import os.path
4-
from os import environ
53
from glob import glob
64
from itertools import chain
7-
import shlex
8-
import sys
95
import logging
6+
import os.path
7+
from os import environ
8+
import shlex
109
import socket
10+
import sys
11+
12+
from botocore.exceptions import EndpointConnectionError
1113

1214
from munch import Munch, munchify
1315
import yaml
@@ -196,10 +198,14 @@ def _apply_functions(d, recursive=False):
196198
logger.warning(f"[{socket.gethostname()}] Offline, using placeholder value for {parameter_name}.")
197199
value = OFFLINE_VALUE
198200
else:
199-
value = _get_ssm_client().get_parameter(
200-
Name=parameter_name,
201-
WithDecryption=True
202-
)['Parameter']['Value']
201+
try:
202+
value = _get_ssm_client().get_parameter(
203+
Name=parameter_name,
204+
WithDecryption=True
205+
)['Parameter']['Value']
206+
except EndpointConnectionError as e:
207+
raise RuntimeError(
208+
"clrenv could not connect to AWS to fetch parameters. If you're developing locally, try setting the offline environment variable (CLRENV_OFFLINE_DEV) to use placeholder values.")
203209
new[key] = value
204210

205211
if not recursive:

0 commit comments

Comments
 (0)