-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sfr 2374 access parameter store (#475)
* SSM service and test functionality
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import boto3 | ||
from typing import Optional | ||
|
||
from logger import create_log | ||
|
||
logger = create_log(__name__) | ||
|
||
ssm_client = boto3.client( | ||
'ssm', | ||
aws_access_key_id=os.environ.get('AWS_ACCESS', None), | ||
aws_secret_access_key=os.environ.get('AWS_SECRET', None), | ||
region_name=os.environ.get('AWS_REGION', None) | ||
) | ||
|
||
def get_parameter(parameter_name: str) -> Optional[dict]: | ||
try: | ||
response = ssm_client.get_parameter( | ||
Name=parameter_name, | ||
WithDecryption=True | ||
) | ||
return response | ||
|
||
except Exception as err: | ||
logger.exception(f"Parameter store retrieval for {parameter_name} failed") | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
from load_env import load_env_file | ||
|
||
from services.ssm_service import get_parameter | ||
|
||
TEST_PARAM = 'arn:aws:ssm:us-east-1:946183545209:parameter/drb/qa/nypl-api/public-key' | ||
|
||
def test_get_parameter(): | ||
value = get_parameter(TEST_PARAM) | ||
|
||
assert value != None |