Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def del_folder(bucket, keys):
loop = asyncio.get_event_loop()
client = aioboto3.client("s3", loop=loop)
await asyncio.gather(*[client.delete_object(Bucket=bucket, Key=key) for key in keys])
await client.close()
async def test_getting_client(event_loop):
"""Simple getting of client."""
aioboto3.DEFAULT_SESSION = None
async with aioboto3.client('ssm', loop=event_loop, region_name='eu-central-1') as client:
assert isinstance(client, AioBaseClient)
async def _func():
async with aioboto3.client('lambda') as cli:
res = await cli.invoke(**invoke_options)
return res
future = run_aio_on_thread(_func())
async def aio_sts_assume_role(src_role_arn, dest_role_arn, dest_external_id=None):
session_name = ''.join(random.choice('0123456789ABCDEF') for i in range(16))
async with aioboto3.client('sts') as sts:
src_role = await sts.assume_role(
RoleArn=src_role_arn, RoleSessionName=session_name
)
async with aioboto3.Session(
aws_access_key_id=src_role['Credentials']['AccessKeyId'],
aws_secret_access_key=src_role['Credentials']['SecretAccessKey'],
aws_session_token=src_role['Credentials']['SessionToken'],
).client('sts') as sts_client:
sts_role = await (
sts_client.assume_role(
RoleArn=dest_role_arn,
RoleSessionName=session_name,
ExternalId=dest_external_id,
)
if dest_external_id
else sts_client.assume_role(
async def setup(self):
self._kms_client = aioboto3.client('kms', **self._kms_client_args)
async def setup(self):
if sys.version_info < (3, 7):
self._loop = asyncio.get_event_loop()
else:
self._loop = asyncio.get_running_loop()
self._s3_client = aioboto3.client('s3', **self._s3_client_args)
await self._crypto_context.setup()