diff --git a/botocore/args.py b/botocore/args.py index cc11f7f5a4..179a0039ef 100644 --- a/botocore/args.py +++ b/botocore/args.py @@ -268,9 +268,8 @@ def compute_client_args( disable_request_compression=( client_config.disable_request_compression ), - account_id_endpoint_mode=( - client_config.account_id_endpoint_mode - ), + client_context_params=client_config.client_context_params, + account_id_endpoint_mode=client_config.account_id_endpoint_mode, ) self._compute_retry_config(config_kwargs) self._compute_connect_timeout(config_kwargs) @@ -657,14 +656,16 @@ def _build_endpoint_resolver( client_endpoint_url=endpoint_url, legacy_endpoint_url=endpoint.host, ) - # botocore does not support client context parameters generically - # for every service. Instead, the s3 config section entries are - # available as client context parameters. In the future, endpoint - # rulesets of services other than s3/s3control may require client - # context parameters. - client_context = ( - s3_config_raw if self._is_s3_service(service_name_raw) else {} - ) + # Client context params for s3 conflict with the available settings + # in the `s3` parameter on the `Config` object. If the same parameter + # is set in both places, the value in the `s3` parameter takes priority. + if client_config is not None: + client_context = client_config.client_context_params or {} + else: + client_context = {} + if self._is_s3_service(service_name_raw): + client_context.update(s3_config_raw) + sig_version = ( client_config.signature_version if client_config is not None @@ -765,9 +766,6 @@ def compute_endpoint_resolver_builtin_defaults( 's3_disable_multiregion_access_points', False ), EPRBuiltins.SDK_ENDPOINT: given_endpoint, - # account ID is calculated later if account based routing is - # enabled and configured for the service - EPRBuiltins.AWS_ACCOUNT_ID: None, } def _compute_user_agent_appid_config(self, config_kwargs): diff --git a/botocore/config.py b/botocore/config.py index 34810c5302..5cabe264c0 100644 --- a/botocore/config.py +++ b/botocore/config.py @@ -221,6 +221,15 @@ class Config: Defaults to None. + :type client_context_params: dict + :param client_context_params: A dictionary of parameters specific to + individual services. If available, valid parameters can be found in + the ``Client Context Parameters`` section of the service client's + documentation. Invalid parameters or ones that are not used by the + specified service will be ignored. + + Defaults to None. + :type account_id_endpoint_mode: str :param account_id_endpoint_mode: Set account ID based endpoint behavior for supported operations. @@ -259,6 +268,7 @@ class Config: ('tcp_keepalive', None), ('request_min_compression_size_bytes', None), ('disable_request_compression', None), + ('client_context_params', None), ('account_id_endpoint_mode', None), ] )