How to change S3 Path to reach S3 compatible storage
Hi there. I've a question about connecting to s3 compatible storage.
$ aws --version aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-100-generic
$ aws --profile=default --endpoint-url=https://my-s3-compatible-storage.com s3 ls 2016-11-11 11:41:59 bucket1 2016-11-11 11:42:03 bucket2 2016-11-11 11:42:08 bucket3 2016-11-11 11:42:12 bucket4
So, I've able to view my buckets I created, however problem is now when I try to upload something.
If I'm in the folder where source folder does not exists I get this: $ aws --endpoint-url=https://my-s3-compatible-storage.com s3 cp foldername s3://bucket1/foldername --recursive [Errno 2] No such file or directory: '/root/.aws/pero/' Completed 1 part(s) with ... file(s) remaining
When I'm in the folder where this do exists: $ aws --endpoint-url=https://my-s3-compatible-storage.com s3 cp foldername s3://bucket1/foldername --recursive upload failed: foldername/test file to s3://bucket1/foldername/test file A client error (InvalidAccessKeyId) occurred when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records.
Debug:
$ aws --endpoint-url=https://my-s3-compatible-storage.com s3 cp foldername s3://bucket1/foldername --recursive --debug 2016-11-14 09:36:58,191 - awscli.clidriver - DEBUG - CLI version: aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-100-generic, botocore version: 0.29.0 2016-11-14 09:36:58,192 - botocore.hooks - DEBUG - Event building-parameter-table.s3.cp: calling handler <function add_cmd_params at 0x7f771a1f2b70> 2016-11-14 09:36:58,194 - botocore.service - DEBUG - Creating service object for: s3 2016-11-14 09:36:58,194 - botocore.base - DEBUG - Attempting to load: aws/s3 2016-11-14 09:36:58,214 - botocore.base - DEBUG - Found data file: /usr/lib/python3/dist-packages/botocore/data/aws/s3.json 2016-11-14 09:36:58,214 - botocore.hooks - DEBUG - Event service-created: calling handler <function register_retries_for_service at 0x7f771a5d08c8> 2016-11-14 09:36:58,214 - botocore.handlers - DEBUG - Registering retry handlers for service: Service(s3) 2016-11-14 09:36:58,215 - botocore.hooks - DEBUG - Event creating-endpoint.s3: calling handler <function maybe_switch_to_s3sigv4 at 0x7f771a5d09d8> 2016-11-14 09:36:58,215 - botocore.credentials - INFO - Found credentials in config file. 2016-11-14 09:36:58,220 - botocore.service - DEBUG - Creating service object for: s3 2016-11-14 09:36:58,221 - botocore.hooks - DEBUG - Event service-created: calling handler <function register_retries_for_service at 0x7f771a5d08c8> 2016-11-14 09:36:58,221 - botocore.handlers - DEBUG - Registering retry handlers for service: Service(s3) 2016-11-14 09:36:58,221 - awscli.customizations.s3.executer - DEBUG - Submitting task: <awscli.customizations.s3.tasks.BasicTask object at 0x7f771a04eb38> 2016-11-14 09:36:58,224 - botocore.service - DEBUG - Creating operation objects for: Service(s3) 2016-11-14 09:36:58,227 - botocore.operation - DEBUG - Operation:PutObject called with kwargs: {'bucket': 'bucket1', 'key': 'foldername/test file', 'body': <_io.BufferedReader name='/home/mislav/Desktop/foldername/test file'>} 2016-11-14 09:36:58,227 - botocore.operation - DEBUG - Creating parameter objects for: Operation:PutObject 2016-11-14 09:36:58,229 - botocore.endpoint - DEBUG - Making request for Operation:PutObject (verify_ssl=True) with params: {'headers': {}, 'payload': <botocore.payload.Payload object at 0x7f771a06bb00>, 'uri_params': {'Key': 'foldername/test file', 'Bucket': 'bucket1'}} 2016-11-14 09:36:58,229 - botocore.endpoint - DEBUG - Building URI for rest endpoint. 2016-11-14 09:36:58,229 - botocore.endpoint - DEBUG - Templated URI path: /{Bucket}/{Key} 2016-11-14 09:36:58,229 - botocore.endpoint - DEBUG - Templated URI query_params: 2016-11-14 09:36:58,230 - botocore.endpoint - DEBUG - Rendered path: /bucket1/foldername/test%20file 2016-11-14 09:36:58,230 - botocore.endpoint - DEBUG - Rendered query_params: 2016-11-14 09:36:58,230 - botocore.hooks - DEBUG - Event before-auth.s3: calling handler <function fix_s3_host at 0x7f771a5d07b8> 2016-11-14 09:36:58,230 - botocore.handlers - DEBUG - Checking for DNS compatible bucket for: https://my-s3-compatible-storage.com/bucket1/foldername/test%20file 2016-11-14 09:36:58,230 - botocore.handlers - DEBUG - URI updated to: https://bucket1.s3.amazonaws.com/foldername/test%20file 2016-11-14 09:36:58,230 - botocore.auth - DEBUG - Calculating signature using hmacv1 auth. 2016-11-14 09:36:58,230 - botocore.auth - DEBUG - HTTP request method: PUT 2016-11-14 09:36:58,230 - botocore.auth - DEBUG - StringToSign: PUT
Mon, 14 Nov 2016 08:36:58 GMT /bucket1/foldername/test%20file 2016-11-14 09:36:58,233 - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [PUT]> 2016-11-14 09:36:59,192 - botocore.response - DEBUG - Response Body: b'\n
' 2016-11-14 09:36:59,193 - botocore.hooks - DEBUG - Event needs-retry.s3.PutObject: calling handler <botocore.retryhandler.RetryHandler object at 0x7f771a0b3b38> 2016-11-14 09:36:59,193 - botocore.retryhandler - DEBUG - No retry needed. 2016-11-14 09:36:59,193 - botocore.hooks - DEBUG - Event after-call.s3.PutObject: calling handler <awscli.errorhandler.ErrorHandler object at 0x7f771a4850b8> 2016-11-14 09:36:59,193 - awscli.errorhandler - DEBUG - HTTP Response Code: 403 2016-11-14 09:36:59,194 - awscli.customizations.s3.tasks - DEBUG - A client error (InvalidAccessKeyId) occurred when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records. Traceback (most recent call last): File "/usr/share/awscli/awscli/customizations/s3/tasks.py", line 77, in _execute_task getattr(filename, filename.operation_name)() File "/usr/share/awscli/awscli/customizations/s3/fileinfo.py", line 213, in upload response_data, http = operate(self.service, 'PutObject', params) File "/usr/share/awscli/awscli/customizations/s3/utils.py", line 128, in operate http_response, response_data = operation.call(**kwargs) File "/usr/lib/python3/dist-packages/botocore/operation.py", line 82, in call parsed=response[1]) File "/usr/lib/python3/dist-packages/botocore/session.py", line 551, in emit return self._events.emit(event_name, **kwargs) File "/usr/lib/python3/dist-packages/botocore/hooks.py", line 156, in emit response = handler(**kwargs) File "/usr/share/awscli/awscli/errorhandler.py", line 75, in call http_status_code=http_response.status_code) awscli.errorhandler.ClientError: A client error (InvalidAccessKeyId) occurred when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records. 2016-11-14 09:36:59,203 - awscli.customizations.s3.executer - DEBUG - Received print task: {'error': True, 'message': 'upload failed: foldername/test file to s3://bucket1/foldername/test file A client error (InvalidAccessKeyId) occurred when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records.'} upload failed: foldername/test file to s3://bucket1/foldername/test file A client error (InvalidAccessKeyId) occurred when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records. InvalidAccessKeyIdThe AWS Access Key Id you provided does not exist in our records. XXXX/S3-002 5C9B3FDB62E876C3 JWjZFewJ+0ihy43pfchAoNRzNR3R3DgHXifM3yeOowcnmtfELDy0GhKxgqM6Up3a3ZTPkVKpsMg=
So I'm wondering how to fix this:
2016-11-14 09:36:58,230 - botocore.handlers - DEBUG - URI updated to: https://bucket1.s3.amazonaws.com/foldername/test%20file
Because of this change, I basically connect to real S3 amazon and not my compatible storage - is there a way to specify the path I want, just like I see buckets when passing --endpoint url?
I've tried in the S3PATH different names of my storage, but nothing.
You will need to upgrade your CLI. The current version is 1.11.21, and the particular handler that's causing the issue for you will not be fired in the new version.