terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Support Setting Endpoint URL via Environment Variable

Sapmatz opened this issue · comments

Description

I am currently conducting some tests using pytest along with LocalStack as my local mock server. For this implementation, I need to configure the endpoint URL for aioboto3. My current requirement would ideally allow this setting to be made via an environment variable (AWS_ENDPOINT_URL).
This becomes critical as this environment is part of a CI/CD process and executes remotely. Considering the nature of my use-case, utilizing the AWS-CLI settings option to configure the URL is not feasible.
The ability to configure the endpoint URL via environment variable is supported in boto3>=1.28.0 (As per the documentation). I would like to extend this feature to aioboto3 for consistent experience.

Feature Request

Ideally being able to configure endpoint URL via the environment variable (AWS_ENDPOINT_URL), similar to how it's implemented in boto3.

Thank you for considering this request!

I'll have a look, this should just reuse the logic in botocore, and failing that it would probably make sense for this itself to end up in aiobotocore

I assumed that since it was implemented in boto3 and not botocore, it might make sense for it to be in aioboto3 and not aiobotocore, but I'm not familiar with if and how you usually match boto3 features.
Even if it's just a reuse, when using the aioboto3 package to create a client, I think it makes sense to be able choose the parameter.

So this seems to already work with the latest aioboto3

import os

os.environ['AWS_ENDPOINT_URL_STS'] = 'http://localhost:1234'

import aioboto3
import asyncio


async def main():
    session = aioboto3.Session()
    async with session.client("sts") as sts:
        resp = await sts.get_caller_identity()
        print(resp)


if __name__ == '__main__':
    asyncio.run(main())

If you run a server on localhost:1234 you'll see requests to it.