I am trying to mock simple Glacier calls (creation and deletion of a Glacier vault) and can't find my way around this (despite being able to achieve such simple mocking with S3, creating a Bucket).
It seems that the mocking of Glacier simply isn't taken into account.
Code is as follows:
import boto3
from moto import mock_glacier
with mock_glacier():
glacier_resource = boto3.resource('glacier', region_name="fake-glacier-region")
vault = glacier_resource.create_vault(accountId='-', vaultName="fake.glacier.name")
And I get the following exception at vault creation:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/<...>/test_mock_glacier.py", line 9, in test_simplest
vault = glacier_resource.create_vault(accountId='-', vaultName="fake.glacier.name")
File "/<...>/.local/lib/python3.7/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/<...>/.local/lib/python3.7/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(*args, **params)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 663, in _make_api_call
operation_model, request_dict, request_context)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 682, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
success_response, exception):
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 256, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
response = handler(**kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 269, in _send
return self.http_session.send(request)
File "/<...>/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 343, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://glacier.fake-glacier-region.amazonaws.com/-/vaults/fake.glacier.name"
I am using boto3 v1.17.49 and moto v2.0.8 that I installed using python3.7 -m pip install 'moto[all]'
Providing a valid AWS region name leads to following exception:
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the CreateVault operation: The security token included in the request is invalid.
(while having set mock AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, AWS_SECURITY_TOKEN
, AWS_SESSION_TOKEN
environment variables (with 'testing'
as value) as stated in moto's README)