botocore icon indicating copy to clipboard operation
botocore copied to clipboard

Cannot set sts_regional_endpoints in Config args

Open ScottMaclure opened this issue 4 years ago • 2 comments

Describe the bug I want to use Config args to set sts_regional_endpoints='regional'. botocore will raise "TypeError: Got unexpected keyword argument 'sts_regional_endpoints'"

Steps to reproduce Test script:

$ cat aws_sts_regional_test.py
import boto3
from botocore.config import Config

boto3.set_stream_logger('')

# Test 1 (works)
# client = boto3.client('sts', region_name='us-west-2', endpoint_url='https://sts.us-west-2.amazonaws.com')

# Test 2 (fails)
client = boto3.client('sts', config=Config(
    connect_timeout=15,
    read_timeout=15,
    retries=dict(max_attempts=10),
    sts_regional_endpoints='regional'
))

# Get token
client.get_session_token()

And run:

$ AWS_PROFILE=my-profile AWS_REGION=us-west-2 python3 aws_sts_regional_test.py
Traceback (most recent call last):
  File "aws_sts_regional_test.py", line 14, in <module>
    sts_regional_endpoints='regional'
  File "/path/to/botocore/config.py", line 173, in __init__
    args, kwargs)
  File "/path/to/botocore/config.py", line 200, in _record_user_provided_options
    'Got unexpected keyword argument \'%s\'' % key)
TypeError: Got unexpected keyword argument 'sts_regional_endpoints'

Expected behavior As per https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html, the docs imply you should be able to set configuration values in the Config object.

Currently, I either have to pass endpoint_url in the client() constructor, or set AWS_STS_REGIONAL_ENDPOINTS=regional in environment variable in order to switch sts over to using the regional endpoints (as per AWS recommendation here: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html)

Debug logs See above.

ScottMaclure avatar Nov 04 '20 04:11 ScottMaclure

@ScottMaclure - Thank you for your post. Currently sts_regional_endpoints is not supported as a config parameters. These are the config supported parameters https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

Currently either you can use it as an environment variable or inside ~/.aws/config file. I am marking it as feature requests for supporting the parameter in config.

swetashre avatar Nov 04 '20 18:11 swetashre

Hey @swetashre , can you share the feature request link? Trying to +1 here

dramaticlly avatar Dec 08 '21 22:12 dramaticlly