@@ -24,6 +24,7 @@ import re
2424from threading import Thread
2525
2626PARENT_FOLDER = os .path .realpath (os .path .join (os .path .dirname (__file__ ), '..' ))
27+ S3_VIRTUAL_ENDPOINT_HOSTNAME = 's3.localhost.localstack.cloud'
2728if os .path .isdir (os .path .join (PARENT_FOLDER , '.venv' )):
2829 sys .path .insert (0 , PARENT_FOLDER )
2930
@@ -153,6 +154,32 @@ def run_in_process():
153154 Modifies the command line args in sys.argv and calls the AWS cli
154155 method directly in this process.
155156 """
157+ profile_name = (
158+ sys .argv [sys .argv .index ('--profile' ) + 1 ] if '--profile' in sys .argv else 'default' )
159+
160+ endpoint_url = (
161+ sys .argv [sys .argv .index ('--endpoint-url' ) + 1 ] if '--endpoint-url' in sys .argv else '' )
162+
163+ if not endpoint_url :
164+ endpoint_url = (
165+ sys .argv [sys .argv .index ('--endpoint' ) + 1 ] if '--endpoint' in sys .argv else '' )
166+
167+ import botocore .session
168+
169+ session = botocore .session .get_session ()
170+
171+ if S3_VIRTUAL_ENDPOINT_HOSTNAME not in endpoint_url :
172+ try :
173+ profiles = session .full_config .get ('profiles' )
174+ if profiles :
175+ current_profile = profiles .get (profile_name )
176+ if (current_profile ['s3' ].get ('addressing_style' ) in ['virtual' , 'auto' ]):
177+ msg = 'Addressing style is being set to \' virtual\' or \' auto\' in the aws config.' + \
178+ ' Please change it to the \' path\' .'
179+ print ('WARNING: %s' % msg )
180+ except KeyError :
181+ pass
182+
156183 import awscli .clidriver
157184 if os .environ .get ('LC_CTYPE' , '' ) == 'UTF-8' :
158185 os .environ ['LC_CTYPE' ] = 'en_US.UTF-8'
0 commit comments