boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
8.97k stars 1.86k forks source link

Enable equivalent of urllib3.util.connection.HAS_IPV6 for boto3 Config or resolve IPv4/IPv6 endpoints in parallel #3632

Open stephteo opened 1 year ago

stephteo commented 1 year ago

Describe the feature

There are cases where traffic on IPv6 is blocked (e.g. using a particular VPN client) and it would be useful to be able to toggle this flag off or have some way to prefer IPv4 over IPv6 for domain resolution.

Otherwise Boto3 should try to get a connection to IPv4 and IPv6 in parallel instead of serially right now (IPv6 -> IPv4) as some AWS services (e.g. "secretsmanager") are configured for dual-stack endpoints.

Use Case

If a user's router and device are configured to have IPv6 enabled, the following:

client = aws_session.client(service_name="secretsmanager")
get_secret_value_response = client.get_secret_value(SecretId=secret_arn)

will fail to get an HTTPS connection to the requested IPv6 domain when getting an AWS service client (e.g. "secretsmanager") and the fallback to IPv4 only happens after the first retry to connect after the connect_timeout time. This can lead to a long waiting time to get a response based on the connect_timeout. It is not ideal to simply reduce the connect_timeout to get around this and just fallback faster to IPv4. Consequently, as a workaround, we have had to temporarily disable the flag urllib3.util.connection.HAS_IPV6 = False so that IPv4 domain resolution is the first one used.

Proposed Solution

The best solution will be if boto3 tries to get a connection to IPv4 and IPv6 at the same time and then this workaround would not be needed.

Other Information

No response

Acknowledgements

SDK version used

1.22.7

Environment details (OS name and version, etc.)

MacOS Monterey 12.6.3

tim-finnigan commented 1 year ago

Hi @stephteo thanks for creating the feature request. We can't guarantee that the team would implement this, it would require some further investigation. In the meantime we encourage others to 👍 this issue and share other use cases if they are also interested in this.