Description
Expected Behavior
import aws_lambda_powertools
should still succeed even if the ENV contains AWS_PROFILE
with a bad value.
Current Behavior
It appears that during import, under at least some conditions, aws_lambda_powertools will attempt to setup an aws client session? I'm not sure I understand why. So if the ENV contains an invalid AWS config, in particular AWS_PROFILE=
or AWS_PROFILE=fakeprofile
, then the import fails with an exception. Which, yes, it's invalid, and I now that I know aws_lambda_powertools
has this behavior I can work around it easily by unsetting the envs. But it still seems like it shouldn't be setting up a session on import?
Possible Solution
Not sure on a solution, but a workaround is to make sure your development environment unsets bad AWS_ envs before attempting to run tests on your python code. :)
Steps to Reproduce (for bugs)
AWS_PROFILE= python -c 'import aws_lambda_powertools'
Environment
- Powertools version used: 1.10.5
- Packaging format (Layers, PyPi): PyPi
- AWS Lambda function runtime:: n/a
- Debugging logs
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/loren/.local/lib/python3.6/site-packages/aws_lambda_powertools/__init__.py", line 9, in <module>
from .tracing import Tracer # noqa: F401
File "/home/loren/.local/lib/python3.6/site-packages/aws_lambda_powertools/tracing/__init__.py", line 6, in <module>
from .tracer import Tracer
File "/home/loren/.local/lib/python3.6/site-packages/aws_lambda_powertools/tracing/tracer.py", line 10, in <module>
import aws_xray_sdk.core
File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/__init__.py", line 10, in <module>
xray_recorder = AsyncAWSXRayRecorder()
File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/recorder.py", line 66, in __init__
self._sampler = DefaultSampler()
File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/sampling/sampler.py", line 25, in __init__
self._connector = ServiceConnector()
File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/sampling/connector.py", line 23, in __init__
self._xray_client = self._create_xray_client()
File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/sampling/connector.py", line 164, in _create_xray_client
aws_access_key_id='', aws_secret_access_key=''
File "/home/loren/.local/lib/python3.6/site-packages/botocore/session.py", line 802, in create_client
verify = self.get_config_variable('ca_bundle')
File "/home/loren/.local/lib/python3.6/site-packages/botocore/session.py", line 241, in get_config_variable
logical_name)
File "/home/loren/.local/lib/python3.6/site-packages/botocore/configprovider.py", line 313, in get_config_variable
return provider.provide()
File "/home/loren/.local/lib/python3.6/site-packages/botocore/configprovider.py", line 410, in provide
value = provider.provide()
File "/home/loren/.local/lib/python3.6/site-packages/botocore/configprovider.py", line 471, in provide
scoped_config = self._session.get_scoped_config()
File "/home/loren/.local/lib/python3.6/site-packages/botocore/session.py", line 340, in get_scoped_config
raise ProfileNotFound(profile=profile_name)
botocore.exceptions.ProfileNotFound: The config profile () could not be found
Metadata
Metadata
Assignees
Labels
Type
Projects
Status