From cdda202bdc82859d68199a421fdd4e6e1ee6635e Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Wed, 18 Sep 2024 08:25:30 -0700 Subject: [PATCH] Factor out AWS_STS_REGIONAL_ENDPOINTS to allow customization (#3257) --- botocore/configprovider.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/botocore/configprovider.py b/botocore/configprovider.py index b0dd09f09f..3341802e53 100644 --- a/botocore/configprovider.py +++ b/botocore/configprovider.py @@ -144,12 +144,6 @@ 'auto', None, ), - 'sts_regional_endpoints': ( - 'sts_regional_endpoints', - 'AWS_STS_REGIONAL_ENDPOINTS', - 'legacy', - None, - ), 'retry_mode': ('retry_mode', 'AWS_RETRY_MODE', 'legacy', None), 'defaults_mode': ('defaults_mode', 'AWS_DEFAULTS_MODE', 'legacy', None), # We can't have a default here for v1 because we need to defer to @@ -175,6 +169,28 @@ None, ), } + +# Evaluate AWS_STS_REGIONAL_ENDPOINTS settings +try: + # This is not a public interface and is subject to abrupt breaking changes. + # Any usage is not advised or supported in external code bases. + from botocore.customizations.sts import ( + sts_default_setting as _sts_default_setting, + ) +except ImportError: + _sts_default_setting = 'legacy' + +_STS_DEFAULT_SETTINGS = { + 'sts_regional_endpoints': ( + 'sts_regional_endpoints', + 'AWS_STS_REGIONAL_ENDPOINTS', + _sts_default_setting, + None, + ), +} +BOTOCORE_DEFAUT_SESSION_VARIABLES.update(_STS_DEFAULT_SETTINGS) + + # A mapping for the s3 specific configuration vars. These are the configuration # vars that typically go in the s3 section of the config file. This mapping # follows the same schema as the previous session variable mapping.