botocore icon indicating copy to clipboard operation
botocore copied to clipboard

Add option to set the source IP address

Open nveloso opened this issue 5 months ago • 0 comments

I was looking into how I could set the source IP address and port when using boto3 but could not find a way. It turns out that I was not the only one looking into that. See #2742.

I looked into the botocore code and tried to add this functionality. Please let me know if something is not right.

I tested my code by creating a simple s3 listing where I specified my config with the new source_address parameter.

boto_config = Config(source_address=('...', 0))

s3 = boto3.client('s3', config=boto_config)
response = s3.list_objects_v2(Bucket='...', Prefix='...')

for content in response['Contents']:
    print(content['Key'])

Then I captured all packets using wireshark and ran my script. Confirmed on wireshark that the traffic to AWS was using the source address I specified in the Config object.

nveloso avatar Sep 17 '24 18:09 nveloso