Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parameters): Allow settings boto3.client() arguments #1079

Closed
gshpychka opened this issue Mar 17, 2022 · 17 comments · Fixed by #1096
Closed

feat(parameters): Allow settings boto3.client() arguments #1079

gshpychka opened this issue Mar 17, 2022 · 17 comments · Fixed by #1096
Assignees
Labels
feature-request feature request

Comments

@gshpychka
Copy link

Is your feature request related to a problem? Please describe.
I'm using VPC endpoints with private DNS disabled, so I have to pass endpoint_url to boto3.client to use the endpoint-specific host name. I am not able to use parameters because this is not supported.

Describe the solution you'd like
Perhaps allowing to pass additional keyword arguments to the client method.

@gshpychka gshpychka added feature-request feature request triage Pending triage from maintainers labels Mar 17, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 17, 2022

Thanks for opening your first issue here! We'll come back to you as soon as we can.

@gshpychka
Copy link
Author

It would be even more amazing if we could go one step further and allow to set these endpoint URLs via environment variables, so that I could use VPC endpoints with no code modification.

@gshpychka
Copy link
Author

Hey, to my understanding this is already supported. Take a look at https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/parameters/#passing-additional-sdk-arguments or https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/parameters/#customizing-boto-configuration

The former only allows me to pass arguments to the client's methods, and the latter allows me to modify the session, but none of these allow me to modify the client initialization.

@ran-isenberg
Copy link
Contributor

look at the appconfig example
config = Config(region_name="us-west-1")
appconf_provider = parameters.AppConfigProvider(environment="my_env", application="my_app", config=config)

config is sent to the client initalization and points it to a specific region.

@gshpychka
Copy link
Author

look at the appconfig example config = Config(region_name="us-west-1") appconf_provider = parameters.AppConfigProvider(environment="my_env", application="my_app", config=config)

config is sent to the client initalization and points it to a specific region.

Right, but the endpoint_url cannot be set with the Config object, it has to be passed as a separate argument to the client.

@gshpychka
Copy link
Author

@ran-isenberg can you confirm that I'm not missing anything here?

@ran-isenberg
Copy link
Contributor

@gshpychka I'm not familiar with this field BUT to my understand, unless you can set it via the config param:
https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
then you can't do.

I think you are right.
What do you use endpoint_url for if i may ask?

@gshpychka
Copy link
Author

@gshpychka I'm not familiar with this field BUT to my understand, unless you can set it via the config param: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html then you can't do.

I think you are right. What do you use endpoint_url for if i may ask?

Yes, exactly. As stated in the issue description, I'm using VPC endpoints with private DNS disabled, so I have to pass endpoint_url to boto3.client to use the endpoint-specific host name.

@ran-isenberg
Copy link
Contributor

@heitorlessa I think we should allow people to send qwargs to the init function, not just config.

@heitorlessa heitorlessa removed the triage Pending triage from maintainers label Apr 5, 2022
@heitorlessa
Copy link
Contributor

Thanks everyone! The more I look into the Parameters utility the more I find we should've accepted a whole boto Client only. It would simplify our logic to maintain it, and also make it easier for customers to stub for unit testing, use snapshot testing with placebo, or in this case pass a different endpoint_url.

We won't be able to add this now due to our pause and bandwidth. I do believe there are other customers who will eventually be blocked by this too, so if anyone could create a PR to accept a Client I'll happily work with you to get it merged as an exception.

Note: I'm following this issue for boto to eventually add support to endpoint_url via environment variables as it's a common ask.

@ran-isenberg
Copy link
Contributor

@heitorlessa A boto client in addition to the session or instead?

@heitorlessa
Copy link
Contributor

heitorlessa commented Apr 5, 2022 via email

@ran-isenberg
Copy link
Contributor

@heitorlessa FYI #1096

@heitorlessa heitorlessa self-assigned this Apr 26, 2022
michaelbrewer added a commit to gyft/aws-lambda-powertools-python that referenced this issue May 1, 2022
@heitorlessa heitorlessa added the pending-release Fix or implementation already in dev waiting to be released label May 19, 2022
@heitorlessa
Copy link
Contributor

Releasing it first thing tomorrow morning @gshpychka

@github-actions
Copy link
Contributor

This is now released under 1.26.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label May 20, 2022
@heitorlessa
Copy link
Contributor

@gshpychka this is available on PyPi and SAR already - a new Lambda Layer will be available in a few hours. Docs are here: https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/parameters/#bring-your-own-boto-client

Please do feel free to reopen if this has not solved your problem. We took liberty to add for others to address a related testing challenge with Parameters too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request
Projects
None yet
3 participants