-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmns_setup.py
More file actions
31 lines (26 loc) · 1.05 KB
/
mns_setup.py
File metadata and controls
31 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import logging
import os
import boto3
from botocore.config import Config
from common.api_clients.authentication import AppRestrictedAuth
from common.api_clients.constants import DEV_ENVIRONMENT
from common.api_clients.mns_service import MnsService
from common.api_clients.mock_mns_service import MockMnsService
from common.cache import Cache
logging.basicConfig(level=logging.INFO)
MNS_TEST_QUEUE_URL = os.getenv("MNS_TEST_QUEUE_URL")
def get_mns_service(mns_env: str = "int"):
if mns_env == DEV_ENVIRONMENT:
logging.info("Dev environment: Using MockMnsService")
return MockMnsService(MNS_TEST_QUEUE_URL)
else:
boto_config = Config(region_name="eu-west-2")
cache = Cache(directory="/tmp")
logging.info("Creating authenticator...")
authenticator = AppRestrictedAuth(
secret_manager_client=boto3.client("secretsmanager", config=boto_config),
environment=mns_env,
cache=cache,
)
logging.info("Authentication Initiated...")
return MnsService(authenticator)