Python code to create AWS S3 resource with proxies config fails inside a container
session = boto3.Session(profile_name="default")
sts = session.client("sts")response = sts.assume_role( RoleArn=assume_role_arn, RoleSessionName=session_name)s3_resource = boto3.resource('s3', aws_access_key_id=response['Credentials']['AccessKeyId'], aws_secret_access_key=response['Credentials']['SecretAccessKey'], aws_session_token=response['Credentials']['SessionToken'], config=Config(proxies={'https': 'http://proxy.server.co.uk:8080'}))
This fails with errorEndpointConnectionError: Could not connect to the endpoint URL: "https://sts.amazonaws.com/"
I made sure my aws config and credentials are properly set and working because if I set proxy server details as env variable then everything works fine
When proxy servers config is set as environment variables everything works fine but that is not approved
os.environ['HTTP_PROXY'] = 'http://proxy.server.co.uk:8080'os.environ['HTTPS_PROXY'] = 'http://proxy.server.co.uk:8080's3_resource = boto3.resource('s3', aws_access_key_id=response['Credentials']['AccessKeyId'], aws_secret_access_key=response['Credentials']['SecretAccessKey'], aws_session_token=response['Credentials']['SessionToken'])
This works fine.