-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[v2] Add configuration to disable host prefix injection #9268
base: v2
Are you sure you want to change the base?
Conversation
This change deviates from the upstream `botocore` to add the ability to disable jost prefix injection. It changes the default for `inject_host_prefix` in the Config object to be `None` (from `True`) so that the value can be determined using the configuration precedence. The fallback if the value remains `True` if it is set to `None` to preserve the CLI default behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a couple small suggestions. I'm also curious if there are existing unit/functional tests where you can actually set the environment variable or create a config file to test that they resolve correctly E2E.
@@ -212,7 +212,6 @@ def compute_client_args(self, service_model, client_config, | |||
proxies_config=client_config.proxies_config, | |||
retries=client_config.retries, | |||
client_cert=client_config.client_cert, | |||
inject_host_prefix=client_config.inject_host_prefix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave this in here and when we compute the value, we can check if this is not None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, not opposed to this. I went for self-containing all of the logic in the compute
method.
def _compute_inject_host_prefix(self, client_config, config_kwargs): | ||
if client_config is not None and client_config.inject_host_prefix is not None: | ||
config_kwargs['inject_host_prefix'] = ( | ||
client_config.inject_host_prefix | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here we can remove client_config
as a parameter and check
if config_kwargs.get('inject_host_prefix') is not None:
# User explicitly set a client config value. Respect it and return.
return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we wait to merge until we figure out the plan for botocore? Want to understand where V1 vs. V2 will land.
{ | ||
"type": "feature", | ||
"category": "configuration", | ||
"description": "Configure if the host prefix is prepended to the request URL in the shared configuration file or via an environment variable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we document the specific environment variable and setting name here?
"description": "Configure if the host prefix is prepended to the request URL in the shared configuration file or via an environment variable" | |
"description": "Allow disabling the prepending of the host prefix to the request URL via ``disable_host_prefix_injection`` in the shared configuration file or the ``AWS_DISABLE_HOST_PREFIX_INJECTION`` environment variable" |
Issue #, if available:
Description of changes:
This change deviates from the upstream
botocore
to add the ability to disable jost prefix injection. It changes the default forinject_host_prefix
in the Config object to beNone
(fromTrue
) so that the value can be determined using the configuration precedence. The fallback if the value remainsTrue
if it is set toNone
to preserve the CLI default behavior.Testing
Tested with the following commands which uses an operation-specific host prefix:
False
, which is the same as the default behavior:True
, which prevents the host prefix from being prepended to the endpoint URL:I also confirmed the behavior applies when using the configuration file setting
disable_host_prefix_injection
, and even when not using a custom endpoint URL.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.