Module: Fog::AWS

Extended by:
Provider
Defined in:
lib/fog/aws/elb.rb,
lib/fog/aws/iam.rb,
lib/fog/aws/rds.rb,
lib/fog/aws/ses.rb,
lib/fog/aws/simpledb.rb,
lib/fog/providers/aws.rb,
lib/fog/aws/cloud_formation.rb,
lib/fog/aws/models/elb/policy.rb,
lib/fog/aws/models/rds/server.rb,
lib/fog/aws/models/rds/servers.rb,
lib/fog/aws/models/elb/listener.rb,
lib/fog/aws/models/elb/policies.rb,
lib/fog/aws/models/rds/snapshot.rb,
lib/fog/aws/models/elb/listeners.rb,
lib/fog/aws/models/rds/parameter.rb,
lib/fog/aws/models/rds/snapshots.rb,
lib/fog/aws/models/rds/parameters.rb,
lib/fog/aws/requests/iam/get_user.rb,
lib/fog/aws/requests/iam/get_group.rb,
lib/fog/aws/requests/iam/list_users.rb,
lib/fog/aws/requests/ses/send_email.rb,
lib/fog/aws/models/elb/load_balancer.rb,
lib/fog/aws/requests/iam/create_user.rb,
lib/fog/aws/requests/iam/delete_user.rb,
lib/fog/aws/requests/iam/list_groups.rb,
lib/fog/aws/requests/iam/update_user.rb,
lib/fog/aws/requests/simpledb/select.rb,
lib/fog/aws/models/elb/load_balancers.rb,
lib/fog/aws/models/rds/security_group.rb,
lib/fog/aws/requests/iam/create_group.rb,
lib/fog/aws/requests/iam/delete_group.rb,
lib/fog/aws/requests/iam/update_group.rb,
lib/fog/aws/models/rds/parameter_group.rb,
lib/fog/aws/models/rds/security_groups.rb,
lib/fog/aws/models/rds/parameter_groups.rb,
lib/fog/aws/requests/ses/get_send_quota.rb,
lib/fog/aws/requests/ses/send_raw_email.rb,
lib/fog/aws/requests/iam/get_user_policy.rb,
lib/fog/aws/requests/iam/put_user_policy.rb,
lib/fog/aws/requests/iam/list_access_keys.rb,
lib/fog/aws/requests/iam/put_group_policy.rb,
lib/fog/aws/requests/iam/add_user_to_group.rb,
lib/fog/aws/requests/iam/create_access_key.rb,
lib/fog/aws/requests/iam/delete_access_key.rb,
lib/fog/aws/requests/iam/get_login_profile.rb,
lib/fog/aws/requests/iam/update_access_key.rb,
lib/fog/aws/requests/simpledb/list_domains.rb,
lib/fog/aws/requests/iam/delete_user_policy.rb,
lib/fog/aws/requests/iam/list_user_policies.rb,
lib/fog/aws/requests/rds/create_db_instance.rb,
lib/fog/aws/requests/rds/create_db_snapshot.rb,
lib/fog/aws/requests/rds/delete_db_instance.rb,
lib/fog/aws/requests/rds/delete_db_snapshot.rb,
lib/fog/aws/requests/rds/modify_db_instance.rb,
lib/fog/aws/requests/rds/reboot_db_instance.rb,
lib/fog/aws/requests/simpledb/create_domain.rb,
lib/fog/aws/requests/simpledb/delete_domain.rb,
lib/fog/aws/requests/iam/delete_group_policy.rb,
lib/fog/aws/requests/iam/list_group_policies.rb,
lib/fog/aws/requests/ses/get_send_statistics.rb,
lib/fog/aws/requests/simpledb/get_attributes.rb,
lib/fog/aws/requests/simpledb/put_attributes.rb,
lib/fog/aws/requests/elb/create_load_balancer.rb,
lib/fog/aws/requests/elb/delete_load_balancer.rb,
lib/fog/aws/requests/iam/create_login_profile.rb,
lib/fog/aws/requests/iam/delete_login_profile.rb,
lib/fog/aws/requests/iam/list_groups_for_user.rb,
lib/fog/aws/requests/iam/update_login_profile.rb,
lib/fog/aws/requests/ses/verify_email_address.rb,
lib/fog/aws/requests/simpledb/domain_metadata.rb,
lib/fog/aws/requests/rds/describe_db_instances.rb,
lib/fog/aws/requests/rds/describe_db_snapshots.rb,
lib/fog/aws/requests/elb/configure_health_check.rb,
lib/fog/aws/requests/iam/remove_user_from_group.rb,
lib/fog/aws/requests/rds/describe_db_parameters.rb,
lib/fog/aws/requests/simpledb/delete_attributes.rb,
lib/fog/aws/requests/elb/describe_load_balancers.rb,
lib/fog/aws/requests/cloud_formation/create_stack.rb,
lib/fog/aws/requests/cloud_formation/delete_stack.rb,
lib/fog/aws/requests/cloud_formation/get_template.rb,
lib/fog/aws/requests/elb/describe_instance_health.rb,
lib/fog/aws/requests/iam/list_server_certificates.rb,
lib/fog/aws/requests/rds/create_db_security_group.rb,
lib/fog/aws/requests/rds/delete_db_security_group.rb,
lib/fog/aws/requests/iam/delete_server_certificate.rb,
lib/fog/aws/requests/iam/list_signing_certificates.rb,
lib/fog/aws/requests/iam/upload_server_certificate.rb,
lib/fog/aws/requests/rds/create_db_parameter_group.rb,
lib/fog/aws/requests/rds/delete_db_parameter_group.rb,
lib/fog/aws/requests/rds/modify_db_parameter_group.rb,
lib/fog/aws/requests/simpledb/batch_put_attributes.rb,
lib/fog/aws/requests/iam/delete_signing_certificate.rb,
lib/fog/aws/requests/iam/update_signing_certificate.rb,
lib/fog/aws/requests/iam/upload_signing_certificate.rb,
lib/fog/aws/requests/cloud_formation/describe_stacks.rb,
lib/fog/aws/requests/elb/delete_load_balancer_policy.rb,
lib/fog/aws/requests/rds/describe_db_security_groups.rb,
lib/fog/aws/requests/rds/describe_db_parameter_groups.rb,
lib/fog/aws/requests/cloud_formation/validate_template.rb,
lib/fog/aws/requests/ses/delete_verified_email_address.rb,
lib/fog/aws/requests/ses/list_verified_email_addresses.rb,
lib/fog/aws/requests/elb/create_load_balancer_listeners.rb,
lib/fog/aws/requests/elb/delete_load_balancer_listeners.rb,
lib/fog/aws/requests/rds/create_db_instance_read_replica.rb,
lib/fog/aws/requests/rds/revoke_db_security_group_ingress.rb,
lib/fog/aws/requests/cloud_formation/describe_stack_events.rb,
lib/fog/aws/requests/elb/create_lb_cookie_stickiness_policy.rb,
lib/fog/aws/requests/elb/create_app_cookie_stickiness_policy.rb,
lib/fog/aws/requests/rds/authorize_db_security_group_ingress.rb,
lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb,
lib/fog/aws/requests/rds/restore_db_instance_from_db_snapshot.rb,
lib/fog/aws/requests/rds/restore_db_instance_to_point_in_time.rb,
lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb,
lib/fog/aws/requests/elb/set_load_balancer_policies_of_listener.rb,
lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb,
lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb,
lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb

Defined Under Namespace

Classes: CloudFormation, ELB, IAM, Mock, RDS, SES, SimpleDB

Class Method Summary collapse

Methods included from Provider

extended, service, services

Class Method Details

.escape(string) ⇒ Object



46
47
48
# File 'lib/fog/providers/aws.rb', line 46

def self.escape(string)
  string.gsub( /([^-a-zA-Z0-9_.~]+)/n ) { |match| '%' + match.unpack( 'H2' * match.size ).join( '%' ).upcase }
end

.indexed_filters(filters) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/providers/aws.rb', line 33

def self.indexed_filters(filters)
  params = {}
  filters.keys.each_with_index do |key, key_index|
    key_index += 1
    params[format('Filter.%d.Name', key_index)] = key
    [*filters[key]].each_with_index do |value, value_index|
      value_index += 1
      params[format('Filter.%d.Value.%d', key_index, value_index)] = value
    end
  end
  params
end

.indexed_param(key, values) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/providers/aws.rb', line 22

def self.indexed_param(key, values)
  params = {}
  unless key.include?('%d')
    key << '.%d'
  end
  [*values].each_with_index do |value, index|
    params[format(key, index + 1)] = value
  end
  params
end

.signed_params(params, options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fog/providers/aws.rb', line 50

def self.signed_params(params, options = {})
  params.merge!({
    'AWSAccessKeyId'    => options[:aws_access_key_id],
    'SignatureMethod'   => 'HmacSHA256',
    'SignatureVersion'  => '2',
    'Timestamp'         => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
    'Version'           => options[:version]
  })

  body = ''
  for key in params.keys.sort
    unless (value = params[key]).nil?
      body << "#{key}=#{escape(value.to_s)}&"
    end
  end
  string_to_sign = "POST\n#{options[:host]}:#{options[:port]}\n#{options[:path]}\n" << body.chop
  signed_string = options[:hmac].sign(string_to_sign)
  body << "Signature=#{escape(Base64.encode64(signed_string).chomp!)}"

  body
end