private function createPresignedUrl(AwsClientInterface $client, CommandInterface $cmd)
 {
     $newCmd = $client->getCommand('CopySnapshot', $cmd->toArray());
     // Avoid infinite recursion by flagging the new command.
     $newCmd->__skipCopySnapshot = true;
     // Serialize a request for the CopySnapshot operation.
     $request = \ILAB_Aws\serialize($newCmd);
     // Create the new endpoint for the target endpoint.
     $endpoint = EndpointProvider::resolve($this->endpointProvider, ['region' => $cmd['SourceRegion'], 'service' => 'ec2'])['endpoint'];
     // Set the request to hit the target endpoint.
     $uri = $request->getUri()->withHost((new Uri($endpoint))->getHost());
     $request = $request->withUri($uri);
     // Create a presigned URL for our generated request.
     $signer = new SignatureV4('ec2', $cmd['SourceRegion']);
     return (string) $signer->presign(SignatureV4::convertPostToGet($request), $client->getCredentials()->wait(), '+1 hour')->getUri();
 }
 public static function _apply_endpoint_provider(callable $value, array &$args)
 {
     if (!isset($args['endpoint'])) {
         // Invoke the endpoint provider and throw if it does not resolve.
         $result = EndpointProvider::resolve($value, ['service' => $args['service'], 'region' => $args['region'], 'scheme' => $args['scheme']]);
         $args['endpoint'] = $result['endpoint'];
         if (isset($result['signatureVersion'])) {
             $args['config']['signature_version'] = $result['signatureVersion'];
         }
         if (isset($result['signingRegion'])) {
             $args['config']['signing_region'] = $result['signingRegion'];
         }
         if (isset($result['signingName'])) {
             $args['config']['signing_name'] = $result['signingName'];
         }
     }
 }