Skip to content

Conversation

@nveloso
Copy link

@nveloso nveloso commented Sep 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant