Question
How to use fake s3 bucket
I tried to use aiobotocore for async work with Ceph, but i have no access to real bucket, then i need to mock s3 bucket to create a fake one
I'm trying to use moto but it anyway want to connect a real bucket
@moto.mock_aws
async def _load_asl_by_type(self, file: File, typ: ContentType) -> AsyncIterable[Tuple[str, Content]]:
session = get_session()
async with session.create_client('s3', region_name='us-east-1', aws_secret_access_key='moto',
aws_access_key_id='moto') as s3:
bucket_name = 'y-bucket'
await s3.create_bucket(Bucket=bucket_name)
await s3.put_object(Bucket=bucket_name, Key=file.path)
try:
async with AsyncFileIO(io=await s3.get_object(Bucket=bucket_name, Key=file.path)) as f:
file.in_progress()
collection = json.load(f)
for name, data in collection.items():
def _spec_load() -> Any:
_logger.info(f"Loading {typ.__qualname__} from {file.path}: {name}")
return spec.load(typ, data, key=name, options=self._options)
obj = await asyncio.get_running_loop().run_in_executor(None, _spec_load)
file.loaded()
yield name, obj
except Exception as error:
_logger.error(f"Failed to load file {file.path}: {error}")
file.failed()
raise error
Traceback:
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host y-bucket.s3.amazonaws.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1133)')]
raise SSLError(endpoint_url=request.url, error=e)
botocore.exceptions.SSLError: SSL validation failed for https://y-bucket.s3.amazonaws.com/ Cannot connect to host y-bucket.s3.amazonaws.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1133)')]
3 86
3