vendor/bundle/ruby/1.8/gems/aws-2.5.6/lib/ec2/ec2.rb
# Bundle a Windows image.
# Internally, it queues the bundling task and shuts down the instance.
# It then takes a snapshot of the Windows volume bundles it, and uploads it to
# S3. After bundling completes, Aws::Ec2#register_image may be used to
# register the new Windows AMI for subsequent launches.
#
#   ec2.bundle_instance('i-e3e24e8a', 'my-awesome-bucket', 'my-win-image-1') #=>
#    [{:aws_update_time => "2008-10-16T13:58:25.000Z",
#      :s3_bucket       => "kd-win-1",
#      :s3_prefix       => "win2pr",
#      :aws_state       => "pending",
#      :aws_id          => "bun-26a7424f",
#      :aws_instance_id => "i-878a25ee",
#      :aws_start_time  => "2008-10-16T13:58:02.000Z"}]
#
Bundle a Windows image.
Internally, it queues the bundling task and shuts down the instance.
It then takes a snapshot of the Windows volume bundles it, and uploads it to
S3. After bundling completes, Aws::Ec2#register_image may be used to
register the new Windows AMI for subsequent launches.


Bundle a Windows image . Internally it queues the bundling task and shuts down the instance . It then takes a snapshot of the Windows volume bundles it and uploads it to S3 . After bundling completes Aws :: Ec2#register_image may be used to register the new Windows AMI for subsequent launches .
def bundle_instance(instance_id, s3_bucket, s3_prefix,
        s3_owner_aws_access_key_id=nil, s3_owner_aws_secret_access_key=nil,
        s3_expires = S3Interface::DEFAULT_EXPIRES_AFTER,
        s3_upload_policy='ec2-bundle-read')
      s3_owner_aws_access_key_id     ||= @aws_access_key_id
      s3_owner_aws_secret_access_key ||= @aws_secret_access_key
      s3_expires = Time.now.utc + s3_expires if s3_expires.is_a?(Fixnum) && (s3_expires < S3Interface::ONE_YEAR_IN_SECONDS)
      policy          = {'expiration' => s3_expires.strftime('%Y-%m-%dT%H:%M:%SZ'),
                         'conditions' => [{'bucket' => s3_bucket},
                                          {'acl' => s3_upload_policy},
                                          ['starts-with', '$key', s3_prefix]]}.to_json
      policy64        = Base64.encode64(policy).gsub("\n", "")
      signed_policy64 = Utils.sign(s3_owner_aws_secret_access_key, policy64)
      params          = {'InstanceId'                       => instance_id,
                         'Storage.S3.AWSAccessKeyId'        => s3_owner_aws_access_key_id,
                         'Storage.S3.UploadPolicy'          => policy64,
                         'Storage.S3.UploadPolicySignature' => signed_policy64,
                         'Storage.S3.Bucket'                => s3_bucket,
                         'Storage.S3.Prefix'                => s3_prefix,
      }
      link            = generate_request("BundleInstance", params)
      request_info(link, QEc2BundleInstanceParser.new)
    rescue Exception
      on_exception
    end
def bundle_instance ( instance_id , s3_bucket , s3_prefix , s3_owner_aws_access_key_id = nil , s3_owner_aws_secret_access_key = nil , s3_expires = S3Interface :: DEFAULT_EXPIRES_AFTER , s3_upload_policy = 'ec2-bundle-read' ) s3_owner_aws_access_key_id ||= @aws_access_key_id s3_owner_aws_secret_access_key ||= @aws_secret_access_key s3_expires = Time . now . utc + s3_expires if s3_expires . is_a? ( Fixnum ) && ( s3_expires < S3Interface :: ONE_YEAR_IN_SECONDS ) policy = { 'expiration' => s3_expires . strftime ( '%Y-%m-%dT%H:%M:%SZ' ) , 'conditions' => [ { 'bucket' => s3_bucket } , { 'acl' => s3_upload_policy } , [ 'starts-with' , '$key' , s3_prefix ] ] } . to_json policy64 = Base64 . encode64 ( policy ) . gsub ( "\n" , "" ) signed_policy64 = Utils . sign ( s3_owner_aws_secret_access_key , policy64 ) params = { 'InstanceId' => instance_id , 'Storage.S3.AWSAccessKeyId' => s3_owner_aws_access_key_id , 'Storage.S3.UploadPolicy' => policy64 , 'Storage.S3.UploadPolicySignature' => signed_policy64 , 'Storage.S3.Bucket' => s3_bucket , 'Storage.S3.Prefix' => s3_prefix , } link = generate_request ( "BundleInstance" , params ) request_info ( link , QEc2BundleInstanceParser . new ) rescue Exception on_exception end
Bundle a Windows image.
Bundle a Windows image .
# S3 access and signatures # policy # fill request params
instance_id
s3_bucket
s3_prefix
s3_owner_aws_access_key_id
s3_owner_aws_secret_access_key
s3_expires
s3_upload_policy