Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63bf249

Browse files
committed
Fix IAM tokens for Elasticsearch client
1 parent ee8f913 commit 63bf249

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ make web
115115

116116
## Change Log
117117

118+
* v0.1.14: Fix AWS tokens when creating Elasticsearch client
118119
* v0.1.11: Add startup/initialization notification for KCL process
119120
* v0.1.10: Bump version of amazon_kclpy to 1.4.1
120121
* v0.1.9: Add initial support for SQS/SNS

‎localstack/utils/aws/aws_stack.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,22 @@ def connect_to_resource(service_name, env=None, region_name=None, endpoint_url=N
132132
return connect_to_service(service_name, client=False, env=env, region_name=region_name, endpoint_url=endpoint_url)
133133

134134

135+
def get_boto3_session():
136+
my_session = None
137+
if CUSTOM_BOTO3_SESSION:
138+
return CUSTOM_BOTO3_SESSION
139+
if CREATE_NEW_SESSION_PER_BOTO3_CONNECTION:
140+
return boto3.session.Session()
141+
# return default session
142+
return boto3
143+
144+
135145
def connect_to_service(service_name, client=True, env=None, region_name=None, endpoint_url=None):
136146
"""
137147
Generic method to obtain an AWS service client using boto3, based on environment, region, or custom endpoint_url.
138148
"""
139149
env = get_environment(env, region_name=region_name)
140-
my_session = None
141-
if CUSTOM_BOTO3_SESSION:
142-
my_session = CUSTOM_BOTO3_SESSION
143-
elif CREATE_NEW_SESSION_PER_BOTO3_CONNECTION:
144-
my_session = boto3.session.Session()
145-
else:
146-
my_session = boto3
150+
my_session = get_boto3_session()
147151
method = my_session.client if client else my_session.resource
148152
if not endpoint_url:
149153
if env.region == REGION_LOCAL:

0 commit comments

Comments
 (0)