Class: Aws::Rds
- Includes:
- AwsBaseInterface
- Defined in:
- lib/rds/rds.rb
Overview
API Reference: docs.amazonwebservices.com/AmazonRDS/latest/APIReference/
Constant Summary collapse
- API_VERSION =
Amazon API version being used
nil
- DEFAULT_HOST =
"rds.amazonaws.com"
- DEFAULT_PATH =
'/'
- DEFAULT_PROTOCOL =
'https'
- DEFAULT_PORT =
443
- @@api =
ENV['RDS_API_VERSION'] || API_VERSION
- @@bench =
AwsBenchmarkingBlock.new
Constants included from AwsBaseInterface
AwsBaseInterface::DEFAULT_SIGNATURE_VERSION
Constants inherited from AwsBase
Instance Attribute Summary
Attributes included from AwsBaseInterface
#aws_access_key_id, #cache, #connection, #last_errors, #last_request, #last_request_id, #last_response, #logger, #params, #signature_version
Class Method Summary collapse
Instance Method Summary collapse
-
#create_db_instance(identifier, instance_class, allocated_storage, master_username, master_password, options = {}) ⇒ Object
identifier: db instance identifier.
-
#delete_db_instance(identifier, final_snapshot_identifier = nil) ⇒ Object
identifier: identifier of db instance to delete.
-
#describe_db_instances(options = {}) ⇒ Object
options: DBInstanceIdentifier MaxRecords Marker.
- #generate_request(action, params = {}) ⇒ Object
-
#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ Rds
constructor
A new instance of Rds.
Methods included from AwsBaseInterface
#cache_hits?, caching, caching=, #caching?, #generate_request2, #get_conn, #hash_params, #init, #multi_thread, #on_exception, #request_cache_or_info, #request_info2, #request_info_impl, #request_info_xml_simple, #signed_service_params, #update_cache
Methods inherited from AwsBase
amazon_problems, amazon_problems=
Constructor Details
#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ Rds
Returns a new instance of Rds.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rds/rds.rb', line 34 def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={}) uri = ENV['RDS_URL'] ? URI.parse(ENV['RDS_URL']) : nil init({ :name => 'RDS', :default_host => uri ? uri.host : DEFAULT_HOST, :default_port => uri ? uri.port : DEFAULT_PORT, :default_service => uri ? uri.path : DEFAULT_PATH, :default_protocol => uri ? uri.scheme : DEFAULT_PROTOCOL }, aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'], aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'], params) end |
Class Method Details
.api ⇒ Object
20 21 22 |
# File 'lib/rds/rds.rb', line 20 def self.api @@api end |
.bench_ec2 ⇒ Object
30 31 32 |
# File 'lib/rds/rds.rb', line 30 def self.bench_ec2 @@bench.service end |
.bench_xml ⇒ Object
26 27 28 |
# File 'lib/rds/rds.rb', line 26 def self.bench_xml @@bench.xml end |
Instance Method Details
#create_db_instance(identifier, instance_class, allocated_storage, master_username, master_password, options = {}) ⇒ Object
identifier: db instance identifier. Must be unique per account per zone. instance_class: db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge See this for other values: docs.amazonwebservices.com/AmazonRDS/latest/APIReference/
options:
db_name: if you want a database created at the same time as the instance, specify :db_name option.
availability_zone: default is random zone.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rds/rds.rb', line 63 def create_db_instance(identifier, instance_class, allocated_storage, master_username, master_password, ={}) params = {} params['DBInstanceIdentifier'] = identifier params['DBInstanceClass'] = instance_class params['AllocatedStorage'] = allocated_storage params['MasterUsername'] = master_username params['MasterUserPassword'] = master_password params['Engine'] = [:engine] || "MySQL5.1" params['DBName'] = [:db_name] if [:db_name] params['AvailabilityZone'] = [:availability_zone] if [:availability_zone] params['PreferredMaintenanceWindow'] = [:preferred_maintenance_window] if [:preferred_maintenance_window] params['BackupRetentionPeriod'] = [:preferred_retention_period] if [:preferred_retention_period] params['PreferredBackupWindow'] = [:preferred_backup_window] if [:preferred_backup_window] @logger.info("Creating DB Instance called #{identifier}") link = generate_request("CreateDBInstance", params) resp = request_info_xml_simple(:rds_connection, @params, link, @logger) rescue Exception on_exception end |
#delete_db_instance(identifier, final_snapshot_identifier = nil) ⇒ Object
identifier: identifier of db instance to delete. final_snapshot_identifier: if specified, RDS will crate a final snapshot before deleting so you can restore it later.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/rds/rds.rb', line 107 def delete_db_instance(identifier, final_snapshot_identifier=nil) @logger.info("Deleting DB Instance - " + identifier.to_s) params = {} params['DBInstanceIdentifier'] = identifier if final_snapshot_identifier params['FinalDBSnapshotIdentifier'] = final_snapshot_identifier else params['SkipFinalSnapshot'] = true end link = generate_request("DeleteDBInstance", params) resp = request_info_xml_simple(:rds_connection, @params, link, @logger) rescue Exception on_exception end |
#describe_db_instances(options = {}) ⇒ Object
options:
DBInstanceIdentifier
MaxRecords
Marker
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rds/rds.rb', line 91 def describe_db_instances(={}) params = {} params['DBInstanceIdentifier'] = [:DBInstanceIdentifier] if [:DBInstanceIdentifier] params['MaxRecords'] = [:MaxRecords] if [:MaxRecords] params['Marker'] = [:Marker] if [:Marker] link = generate_request("DescribeDBInstances", params) resp = request_info_xml_simple(:rds_connection, @params, link, @logger) rescue Exception on_exception end |
#generate_request(action, params = {}) ⇒ Object
46 47 48 |
# File 'lib/rds/rds.rb', line 46 def generate_request(action, params={}) generate_request2(@aws_access_key_id, @aws_secret_access_key, action, @@api, @params, params) end |