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, #last_errors, #last_request, #last_request_id, #last_response, #logger, #params, #signature_version
Class Method Summary collapse
Instance Method Summary collapse
- #authorize_db_security_group_ingress_ec2group(group_name, ec2_group_name, ec2_group_owner_id, options = {}) ⇒ Object
- #authorize_db_security_group_ingress_range(group_name, ip_range, options = {}) ⇒ Object
-
#create_db_instance(identifier, instance_class, allocated_storage, master_username, master_password, options = {}) ⇒ Object
identifier: db instance identifier.
- #create_db_security_group(group_name, description, options = {}) ⇒ Object
-
#delete_db_instance(identifier, final_snapshot_identifier = nil) ⇒ Object
identifier: identifier of db instance to delete.
- #delete_db_security_group(group_name, options = {}) ⇒ Object
-
#describe_db_instances(options = {}) ⇒ Object
options: DBInstanceIdentifier MaxRecords Marker.
- #describe_db_security_groups(options = {}) ⇒ Object
- #do_request(action, params, options = {}) ⇒ Object
-
#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ Rds
constructor
A new instance of Rds.
- #revoke_db_security_group_ingress(group_name, ip_range, options = {}) ⇒ Object
Methods included from AwsBaseInterface
#cache_hits?, caching, caching=, #caching?, #close_conn, #close_connection, #connection, #escape_params, #generate_request, #generate_request2, #get_conn, #hash_params, #init, #multi_thread, #on_exception, #request_cache_or_info, #request_info2, #request_info3, #request_info_impl, #request_info_xml_simple, #request_info_xml_simple3, #signed_service_params, #symbolize, #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.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rds/rds.rb', line 44 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, :api_version => API_VERSION}, 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
23 24 25 |
# File 'lib/rds/rds.rb', line 23 def self.api @@api end |
.bench ⇒ Object
30 31 32 |
# File 'lib/rds/rds.rb', line 30 def self.bench @@bench end |
.bench_ec2 ⇒ Object
39 40 41 |
# File 'lib/rds/rds.rb', line 39 def self.bench_ec2 @@bench.service end |
.bench_xml ⇒ Object
34 35 36 |
# File 'lib/rds/rds.rb', line 34 def self.bench_xml @@bench.xml end |
.connection_name ⇒ Object
19 20 21 |
# File 'lib/rds/rds.rb', line 19 def self.connection_name :rds_connection end |
Instance Method Details
#authorize_db_security_group_ingress_ec2group(group_name, ec2_group_name, ec2_group_owner_id, options = {}) ⇒ Object
189 190 191 192 193 194 195 196 197 |
# File 'lib/rds/rds.rb', line 189 def (group_name, ec2_group_name, ec2_group_owner_id, ={}) params = {} params['DBSecurityGroupName'] = group_name params['EC2SecurityGroupOwnerId'] = ec2_group_owner_id params['EC2SecurityGroupName'] = ec2_group_name link = do_request("AuthorizeDBSecurityGroupIngress", params) rescue Exception on_exception end |
#authorize_db_security_group_ingress_range(group_name, ip_range, options = {}) ⇒ Object
200 201 202 203 204 205 206 207 |
# File 'lib/rds/rds.rb', line 200 def (group_name, ip_range, ={}) params = {} params['DBSecurityGroupName'] = group_name params['CIDRIP'] = ip_range link = do_request("AuthorizeDBSecurityGroupIngress", params) rescue Exception on_exception end |
#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.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rds/rds.rb', line 89 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 = do_request("CreateDBInstance", params, :pull_out_single=>[:create_db_instance_result, :db_instance]) rescue Exception on_exception end |
#create_db_security_group(group_name, description, options = {}) ⇒ Object
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/rds/rds.rb', line 153 def create_db_security_group(group_name, description, ={}) params = {} params['DBSecurityGroupName'] = group_name params['DBSecurityGroupDescription'] = description link = do_request("CreateDBSecurityGroup", params, :pull_out_single => [:create_db_security_group_result, :db_security_group]) 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.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/rds/rds.rb', line 135 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 = do_request("DeleteDBInstance", params, :pull_out_single=>[:delete_db_instance_result, :db_instance]) rescue Exception on_exception end |
#delete_db_security_group(group_name, options = {}) ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/rds/rds.rb', line 165 def delete_db_security_group(group_name, ={}) params = {} params['DBSecurityGroupName'] = group_name link = do_request("DeleteDBSecurityGroup", params) rescue Exception on_exception end |
#describe_db_instances(options = {}) ⇒ Object
options:
DBInstanceIdentifier
MaxRecords
Marker
Returns array of instances as hashes. Response metadata can be retreived by calling array.response_metadata on the returned array.
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/rds/rds.rb', line 120 def describe_db_instances(={}) params = {} params['DBInstanceIdentifier'] = [:db_instance_identifier] if [:db_instance_identifier] params['MaxRecords'] = [:max_records] if [:max_records] params['Marker'] = [:marker] if [:marker] resp = do_request("DescribeDBInstances", params, :pull_out_array=>[:describe_db_instances_result, :db_instances]) rescue Exception on_exception end |
#describe_db_security_groups(options = {}) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/rds/rds.rb', line 176 def describe_db_security_groups(={}) params = {} params['DBSecurityGroupName'] = [:DBSecurityGroupName] if [:DBSecurityGroupName] params['MaxRecords'] = [:MaxRecords] if [:MaxRecords] link = do_request("DescribeDBSecurityGroups", params, :pull_out_array=>[:describe_db_security_groups_result, :db_security_groups], :wrapper=>:db_security_group) rescue Exception on_exception end |
#do_request(action, params, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rds/rds.rb', line 58 def do_request(action, params, ={}) link = generate_request(action, params) resp = request_info_xml_simple(self.class.connection_name, @params, link, @logger, :group_tags =>{"DBInstances" =>"DBInstance", "DBParameterGroups"=>"DBParameterGroup", "DBSecurityGroups" =>"DBSecurityGroup", "EC2SecurityGroups"=>"EC2SecurityGroup", "IPRanges" =>"IPRange"}, :force_array =>["DBInstances", "DBParameterGroups", "DBSecurityGroups", "EC2SecurityGroups", "IPRanges"], :pull_out_array =>[:pull_out_array], :pull_out_single=>[:pull_out_single], :wrapper =>[:wrapper]) end |
#revoke_db_security_group_ingress(group_name, ip_range, options = {}) ⇒ Object
210 211 212 213 214 215 216 217 |
# File 'lib/rds/rds.rb', line 210 def revoke_db_security_group_ingress(group_name, ip_range, ={}) params = {} params['DBSecurityGroupName'] = group_name params['CIDRIP'] = ip_range link = do_request("RevokeDBSecurityGroupIngress", params) rescue Exception on_exception end |