Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16714

boto3.resource to create AWS S3 resource fails when proxies config is used

$
0
0

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.

Note: I am running these calls in a container with firewall restrictions, that's the reason I need to use proxy config


Viewing all articles
Browse latest Browse all 16714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>