Skip to content

Commit fa07d0f

Browse files
committed
CMR-10388: Fixing getting parameter store values.
1 parent 1f43772 commit fa07d0f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

subscription/src/access_control.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AccessControl:
88
"""Encapsulates Access Control API.
9-
This class needs the following environment variables set:
9+
This class needs the following environment variables set with an exxample value:
1010
For local development:
1111
ACCESS_CONTROL_URL=http://localhost:3011/access-control
1212
@@ -19,7 +19,7 @@ class AccessControl:
1919
2020
Example Use of this class
2121
access_control = AccessControl()
22-
response = access_control.get_permissions('eereiter', 'C1200484253-CMR_ONLY')
22+
response = access_control.get_permissions('user1', 'C1200484253-CMR_ONLY')
2323
The call is the same as 'curl https://cmr.sit.earthdata.nasa.gov/access-control/permissions?user_id=eereiter&concept_id=C1200484253-CMR_ONLY'
2424
Return is either None (Null or Nil) (if check on response is false) or
2525
{"C1200484253-CMR_ONLY":["read","update","delete","order"]}
@@ -55,6 +55,7 @@ def get_url_from_parameter_store(self):
5555
port_param_name = f"{pre_fix}CMR_ACCESS_CONTROL_PORT"
5656
host_param_name = f"{pre_fix}CMR_ACCESS_CONTROL_HOST"
5757
context_param_name = f"{pre_fix}CMR_ACCESS_CONTROL_RELATIVE_ROOT_URL"
58+
logger.info(f"protocol_param_name: {protocol_param_name}")
5859

5960
env_vars = Env_Vars()
6061
protocol = env_vars.get_var(name=protocol_param_name)

subscription/src/env_vars.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ def __init__(self):
1212
self.ssm_client = boto3.client('ssm', region_name=os.getenv("AWS_REGION"))
1313

1414
def get_var(self, name, decryption=False):
15-
value = os.getenv(name)
15+
logger.debug(f"Getting the environment variable called {name}")
16+
parts = name.split('/')
17+
os_name = next(part for part in reversed(parts) if part)
18+
19+
value = os.getenv(os_name)
1620

1721
if not value:
1822
try:

0 commit comments

Comments
 (0)