class AWS::EC2::Client::V20140901
Public Instance Methods
copy_snapshot(params = {})
click to toggle source
# File lib/aws/ec2/client.rb, line 112 def copy_snapshot(params = {}) # Adding logic to auto-compute the destination group and presigned # url params for the copy snapshot operation. This is necessary # when calling copy snapshot on snapshots for encrypted volumes. # This addition should be transparent to the API user. params = params.dup params[:destination_region] = @region params[:presigned_url] = presigned_copy_snapshot_url(params) basic_copy_snapshot(params) end
Also aliased as: basic_copy_snapshot
Private Instance Methods
presigned_copy_snapshot_url(params)
click to toggle source
# File lib/aws/ec2/client.rb, line 125 def presigned_copy_snapshot_url(params) token = credential_provider.session_token client = self.with_options(:ec2_region => params[:source_region]) req = client.build_request(:copy_snapshot, params) now = req.remove_param("Timestamp").value now = Time.parse(now).strftime("%Y%m%dT%H%M%SZ") req.add_param("X-Amz-Algorithm", "AWS4-HMAC-SHA256") req.add_param("X-Amz-Date", now) req.add_param("X-Amz-SignedHeaders", 'host') req.add_param("X-Amz-Expires", "3600") req.add_param('X-Amz-Security-Token', token) if token req.add_param("X-Amz-Credential", client.v4_signer.credential(now)) req.http_method = 'GET' req.uri = '/?' + req.url_encoded_params req.body = '' req.headers.clear req.headers['host'] = client.config.ec2_endpoint key = client.v4_signer.derive_key(now) sig = client.v4_signer.signature(req, key, now, client.v4_signer.class::EMPTY_DIGEST) req.add_param('X-Amz-Signature', sig) req.endpoint + '/?' + req.url_encoded_params end