Skip to content

Commit

Permalink
feat: add proxy config to boto3 client (#7)
Browse files Browse the repository at this point in the history
Adds the certificate bundle which has the proxyRootCA, to the boto3 client config in case of component running behind a proxy.
  • Loading branch information
vabhasin authored Apr 8, 2022
1 parent 63c5898 commit 195838d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/metric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

import boto3
from botocore import credentials, exceptions
from botocore import credentials, exceptions, config
from botocore.session import get_session
from src import utils

Expand All @@ -19,7 +19,8 @@ def __init__(self, region):
session = get_session()
if container_creds is not None:
session._credentials = container_creds
self.client = boto3.Session(botocore_session=session).client('cloudwatch', region)
self.client = boto3.Session(botocore_session=session).client(
'cloudwatch', region, config=config.Config(proxies_config={'proxy_ca_bundle': utils.GG_ROOT_CA_PATH}))
else:
raise exceptions.CredentialRetrievalError(
provider=credentials.ContainerProvider.METHOD,
Expand Down
1 change: 1 addition & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
DEFAULT_PUBSUB_TO_IOT_CORE = 'False'

GG_CORE_NAME = os.environ.get("AWS_IOT_THING_NAME")
GG_ROOT_CA_PATH = os.environ.get("GG_ROOT_CA_PATH")

RESPONSE = "response"
RESPONSE_FIELD_RID = "id"
Expand Down

0 comments on commit 195838d

Please sign in to comment.