botocore icon indicating copy to clipboard operation
botocore copied to clipboard

Deprecate Usage of `sslComonName` in Endpoint Creation

Open dlm6693 opened this issue 3 years ago • 21 comments

The Problem

Currently when creating a service client, an sslCommonName attribute may be used for endpoint construction in unique cases. The format of sslCommonName is typically {region}.{service}.{dnsSuffix}, as opposed to the more common {service}.{region}.{dnsSuffix}. This usage originated from a time where Python versions (<2.7) didn't supply an SSL module, requiring specific certificate formats.

Now that the library only support Python 3.7+, we'll be deprecating the usage of sslCommonName to standardize Boto3 with all other AWS SDKs. This will also resolve long running issues of services such as SQS and GuardDuty being incompatible with certain VPC endpoint configurations.

Required Actions

In the immediate term, we will start raising a deprecation warning when sslCommonName is used. This is to alert customers of the upcoming change and provide time to make any required changes.

For most users, this will not require any changes. The URL will automatically update when the next minor version (1.28.0) is released, and clients will continue to operate the same. For any users with strict network rules, explicitly allow listing domains, you will need to add support for {service}.{region}.{dnsSuffix} as demonstrated below:

Old Format: https://us-west-2.sqs.amazonaws.com New Format: https://sqs.us-west-2.amazonaws.com

Warning Mitigation Strategy

  1. If you wish to ensure that your application does not use sslCommonName now or test the impending deprecation, we have created a new environment variable BOTO_DISABLE_COMMONNAME. Setting this to true will suppress the warning and convert to the new hostname format.
  2. If you are concerned about this change causing disruptions, you can pin your version of botocore to <1.28.0 until you are ready to migrate.
  3. If you are only concerned about silencing the warning in your logs, use warnings.filterwarnings when instantiating a new service client.
import warnings
warnings.filterwarnings('ignore', category=FutureWarning, module='botocore.client')

Other Information

Endpoint Docs: https://docs.aws.amazon.com/general/latest/gr/rande.html Related Issues: https://github.com/boto/botocore/issues/2376, https://github.com/boto/boto3/issues/1900, https://github.com/boto/boto3/issues/3311, https://github.com/boto/botocore/issues/2683

dlm6693 avatar Jun 22 '22 18:06 dlm6693

The EMR client now gives the following warning:

The elasticmapreduce client is currently using a deprecated endpoint: elasticmapreduce.us-east-1.amazonaws.com. In the next minor version this will be moved to elasticmapreduce.us-east-1.amazonaws.com.

Note that the URL's are the same. What is the actual change for this service?

bblommers avatar Sep 04 '22 18:09 bblommers

Oh interesting! Thank you for raising this. I guess for whatever reason the SSL common name for EMR is the same as the standard host name. It will follow the {service}.{region}.{dnsSuffix} convention as outlined above so it won't actually change. I don't think we will spend engineering resources to cherry pick common names that follow this pattern as they will be fully deprecated in the next minor version bump. Feel free to suppress this one or any others like it if needed. A decent workaround would be to add a regular expression to match the message in the message parameter of warnings.filterwarnings. Something like the following should do the trick.

warnings.filterwarnings(
    'ignore', 
    category=FutureWarning, 
    module='botocore.client', 
    message='.*elasticmapreduce.us-east-1.amazonaws.com.*'
)

dlm6693 avatar Sep 04 '22 20:09 dlm6693

Awesome - thanks for the info @dlm6693!

bblommers avatar Sep 04 '22 20:09 bblommers

Please notice that boto3 sqs client is creating queues with the soon to be deprecated format. We started using this:

    `queue = sqs_client.create_queue(QueueName=f"{org.name.lower()}-queue", tags={'ClientName': org.name})`

to create queues for our clients, but the returned queue is giving us this deprecaion warning:

FutureWarning: The sqs client is currently using a deprecated endpoint: queue.amazonaws.com. In the next minor version this will be moved to sqs.us-east-1.amazonaws.com. See https://github.com/boto/botocore/issues/2705 for more details.

boto3 should create a properly formatted queues a while before you break the old ones IMO

NotSoShaby avatar Sep 06 '22 13:09 NotSoShaby

Hi @NotSoShaby, both formats will continue to work for the foreseeable future. The only difference with this change is the hostname used for routing requests from Boto3. The new format can be accessed now with the BOTO_DISABLE_COMMONNAME environment variable if you wish to transition early.

The primary reason for the warning is to make sure users can make any firewall adjustments if needed since the domain is changing.

nateprewitt avatar Sep 06 '22 14:09 nateprewitt

Hi @NotSoShaby if I'm understanding you correctly, you can create a SQS endpoint with the non-deprecated format by enabling the environment variable described above.

dlm6693 avatar Sep 06 '22 14:09 dlm6693

@nateprewitt thanks, will try it out. assuming it should be set to true? @dlm6693 no, I wasn't using the env variable flag will update once i tested it.

thanks for the quick response :)

NotSoShaby avatar Sep 07 '22 06:09 NotSoShaby

Yep set to true

dlm6693 avatar Sep 07 '22 15:09 dlm6693

I'm getting the deprecation warning even though the DNS name is taken from CloudFormation output of an AWS::SQS:Queue Ref value and have confirmed this environment variable to be set as: https://sqs.eu-north-1.amazonaws.com/XXXXX/FILTERED-SQSQueue-1MANR5OR9C65A on lambda which is then correctly read by our code. Is this by design?

lehmat avatar Sep 22 '22 08:09 lehmat

I am getting the warning on rds FutureWarning: The rds client is currently using a deprecated endpoint: rds.amazonaws.com. In the next minor version this will be moved to rds.us-east-1.amazonaws.com. See https://github.com/boto/botocore/issues/2705 for more details.

I verified when I create the client I pass in the region

tikicoder avatar Sep 29 '22 16:09 tikicoder

Hi @tikicoder. That is expected behavior. The sslCommonName template for this service and region is defined as {service}.{dnsSuffix} in endpoints.json. You can confirm the actual endpoint being used for operation calls by running the following.

import boto3
rds_client = boto3.client('rds', region_name='us-east-1')
rds_client._endpoint
> rds(https://rds.amazonaws.com)

dlm6693 avatar Sep 29 '22 17:09 dlm6693

@dlm6693 Thanks. I am presuming boto will be updated to fix the issue? It looks like I could by passing in an extra config, but that seems like overkill on something that I would presume should work since I am passing in all the required values. It is also the only one of the clients, I have used, so far that does this.

tikicoder avatar Sep 29 '22 17:09 tikicoder

@tikicoder of course hence the deprecation warning and the creation of this issue. As documented at the top of this issue, you can disable the behavior now by setting the environment variable BOTO_DISABLE_COMMONNAME to true

dlm6693 avatar Sep 29 '22 17:09 dlm6693

@dlm6693 The warning doesn't bother me as long as I can explain it. Instead of setting an environment variable, I would have preferred a flag. I either have to manually set the environment variable or I have to tell people how to do that. Fortunately, I have spun up my own boto helper system so it's not that big of an issue.

Thanks for the quick replies

tikicoder avatar Sep 29 '22 17:09 tikicoder

hello, I am new to python botocore and the ecosystem; I am trying to run localstack and celery workers via docker compose, and I get similar error: botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://eu-east-1.queue.amazonaws.com/" in /usr/local/lib/python3.8/site-packages/celery/worker/consumer/consumer.py:367: CPendingDeprecationWarning

how would you advice to adjust the configurations?

Thank you

gheorghina avatar Sep 29 '22 19:09 gheorghina

@gheorghina I suspect that is because the eu-east-1 region does not exist. Here is a list of available regions https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions

dlm6693 avatar Sep 29 '22 20:09 dlm6693

for sure I am missing some configurations, as you are right, I expected it to be eu-central-1, I have no idea how botocore solves it to eu-east-1

gheorghina avatar Sep 29 '22 20:09 gheorghina

@gheorghina if you continue to run into problems feel free to open up a new issue. It seems to be unrelated to this one. I have no issue connecting to SQS using eu-central-1. Please add boto3.set_stream_logger() to your script and share the output.

dlm6693 avatar Sep 29 '22 20:09 dlm6693

I got a warning

/usr/local/lib/python3.10/site-packages/botocore/client.py:625: FutureWarning: The sqs client is currently using a deprecated endpoint: eu-west-1.queue.amazonaws.com. In the next minor version this will be moved to sqs.eu-west-1.amazonaws.com.

But all of my endpoints are already using service.zone.amazonaws.com format and specifically eu-west-1.queue.amazonaws.com isn't findable anywhere :(

vbhjckfd avatar Oct 06 '22 11:10 vbhjckfd

@vbhjckfd have you tried using the environment variable described above?

dlm6693 avatar Oct 06 '22 13:10 dlm6693

@vbhjckfd have you tried using the environment variable described above?

Setting env variable BOTO_DISABLE_COMMONNAME to true eliminates warning and still keeps my script working.

vbhjckfd avatar Oct 11 '22 11:10 vbhjckfd

Just wondering is botocore>=1.28.0 still use sslCommonName by default? And for disable it still required to set env BOTO_DISABLE_COMMONNAME=true

Taragolis avatar Oct 26 '22 14:10 Taragolis

@Taragolis yes. We'll need to update this document, but only a select group of services (s3 and s3-control) have had the new methodology of endpoint resolution enabled. The rest will come soon, but until that time, sslCommonName will be used by default when defined for all other services.

dlm6693 avatar Oct 26 '22 16:10 dlm6693

After conferring with the team, BOTO_DISABLE_COMMNAME will no longer be needed to suppress the deprecation warning for the NEXT minor version 1.29.0. That will be released in the near future. I've updated the issue accordingly.

dlm6693 avatar Oct 26 '22 16:10 dlm6693

@dlm6693 many thanks for detail explanation!

Taragolis avatar Oct 26 '22 18:10 Taragolis

Resolving now that we've had botocore 1.29.x out for a couple weeks. Please feel free to let us know if you encounter any issues but the migration should be complete at this point.

nateprewitt avatar Nov 16 '22 23:11 nateprewitt