You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_get_default_session() always returns a defaulted Session item, not allowing you to modify it. Creating the client() from that doesn't honor the kwargs either.
This all appears to be designed to use a single global Session, but I must admit, I don't see a benefit to that. We should be able to create multiple sessions, into multiple regions, within a given "account".
I believe that, assuming you want to use the global space, would be to allow for multiple global sessions, specified by the kwargs passed in. Alternatively, could you just only support the global entry for a client/resourse request with no kwargs?
def client(*args, **kwargs):
if not kwargs:
return _get_default_session().client(*args, **kwargs)
else:
return Session(**kwargs).client(*args, **kwargs)
With the change above:
import localstack_client.session as boto3
c = boto3.client('lambda', region_name='us-west-2')
c._client_config.region_name
'us-west-2'
c2 = boto3.client('lambda')
c2._client_config.region_name
'us-east-1'
The text was updated successfully, but these errors were encountered:
josephpohlmann
added a commit
to josephpohlmann/localstack-python-client
that referenced
this issue
Jul 20, 2021
Simply stated, this doesn't work (as it always assumes region of 'us-east-1'):
import localstack_client.session as boto3
lambda_client = boto3.client('lambda', region_name='us-west-2')
lambda_client.invoke(...)
But this works:
from localstack_client.session import Session
sess = Session(region_name='us-west-2')
lambda_client = sess.client('lambda')
This is because, if you look at the code,
def client(*args, **kwargs):
return _get_default_session().client(*args, **kwargs)
_get_default_session() always returns a defaulted Session item, not allowing you to modify it. Creating the client() from that doesn't honor the kwargs either.
This all appears to be designed to use a single global Session, but I must admit, I don't see a benefit to that. We should be able to create multiple sessions, into multiple regions, within a given "account".
I believe that, assuming you want to use the global space, would be to allow for multiple global sessions, specified by the kwargs passed in. Alternatively, could you just only support the global entry for a client/resourse request with no kwargs?
def client(*args, **kwargs):
if not kwargs:
return _get_default_session().client(*args, **kwargs)
else:
return Session(**kwargs).client(*args, **kwargs)
With the change above:
The text was updated successfully, but these errors were encountered: