|  | 
| 30 | 30 | from awscli.customizations.commands import BasicCommand | 
| 31 | 31 | from botocore.exceptions import ClientError | 
| 32 | 32 | from awscli.schema import ParameterRequiredError | 
| 33 |  | - | 
|  | 33 | +from awscli.utils import create_nested_client | 
| 34 | 34 | 
 | 
| 35 | 35 | LOG = logging.getLogger(__name__) | 
| 36 | 36 | DATE_FORMAT = '%Y%m%dT%H%M%SZ' | 
| @@ -193,7 +193,7 @@ def _get_bucket_region(self, bucket_name): | 
| 193 | 193 |     def _create_client(self, region_name): | 
| 194 | 194 |         """Creates an Amazon S3 client for the given region name""" | 
| 195 | 195 |         if region_name not in self._client_cache: | 
| 196 |  | -            client = self._session.create_client('s3', region_name) | 
|  | 196 | +            client = create_nested_client(self._session, 's3', region_name=region_name) | 
| 197 | 197 |             # Remove the CLI error event that prevents exceptions. | 
| 198 | 198 |             self._client_cache[region_name] = client | 
| 199 | 199 |         return self._client_cache[region_name] | 
| @@ -753,13 +753,13 @@ def setup_services(self, parsed_globals): | 
| 753 | 753 |             self._session, self._source_region) | 
| 754 | 754 |         client_args = {'region_name': parsed_globals.region, | 
| 755 | 755 |                        'verify': parsed_globals.verify_ssl} | 
| 756 |  | -        self.organization_client = self._session.create_client( | 
| 757 |  | -            'organizations', **client_args) | 
|  | 756 | +        self.organization_client = create_nested_client( | 
|  | 757 | +            self._session, 'organizations', **client_args) | 
| 758 | 758 | 
 | 
| 759 | 759 |         if parsed_globals.endpoint_url is not None: | 
| 760 | 760 |             client_args['endpoint_url'] = parsed_globals.endpoint_url | 
| 761 |  | -        self.cloudtrail_client = self._session.create_client( | 
| 762 |  | -            'cloudtrail', **client_args) | 
|  | 761 | +        self.cloudtrail_client = create_nested_client( | 
|  | 762 | +            self._session, 'cloudtrail', **client_args) | 
| 763 | 763 | 
 | 
| 764 | 764 |     def _call(self): | 
| 765 | 765 |         traverser = create_digest_traverser( | 
|  | 
0 commit comments