code: def connect(self, creds):
          
          def _conn_help(*args, **kwargs):
              return _connect_secureish(
                  *args,
                  provider=creds,
                  calling_format=self.calling_format(),
                  auth_region_name=self.region,
                  **kwargs)
  
          # If WALE_S3_ENDPOINT is set, do not attempt to guess
          # the right calling conventions and instead honor the explicit
          # settings within WALE_S3_ENDPOINT.
          impl = os.getenv('WALE_S3_ENDPOINT')
          if impl:
              return connection.S3Connection(**_s3connection_opts_from_uri(impl))
  
          # Check if subdomain format compatible: if so, use the
          # BUCKETNAME.s3.amazonaws.com hostname to communicate with the
          # bucket.
          if self.calling_format is connection.SubdomainCallingFormat:
              return _conn_help(host='s3.amazonaws.com')
  
          # Check if OrdinaryCallingFormat compatible, but also see if
          # the endpoint has already been set, in which case only
          # setting the host= flag is necessary.
          assert self.calling_format is connection.OrdinaryCallingFormat
          assert self.ordinary_endpoint is not None
          return _conn_help(host=self.ordinary_endpoint)
docs: Return a boto S3Connection set up with great care.
  
          This includes TLS settings, calling format selection, and
          region detection.
  
          The credentials are applied by the caller because in many
          cases (instance-profile IAM) it is possible for those
          credentials to fluctuate rapidly.  By comparison, region
          fluctuations of a bucket name are not nearly so likely versus
          the gains of not looking up a bucket's region over and over.