| Class | RightAws::RdsInterface |
| In: |
lib/rds/right_rds_interface.rb
|
| Parent: | RightAwsBase |
| API_VERSION | = | "2009-10-16" |
| DEFAULT_HOST | = | 'rds.amazonaws.com' |
| DEFAULT_PORT | = | 443 |
| DEFAULT_PROTOCOL | = | 'https' |
| DEFAULT_PATH | = | '/' |
| DEFAULT_INSTANCE_CLASS | = | 'db.m1.small' |
| INSTANCE_CLASSES | = | ['db.m1.small', 'db.m1.large', 'db.m1.xlarge', 'db.m2.2xlarge', 'db.m2.4xlarge'] |
Create a new handle to a RDS account. All handles share the same per process or per thread HTTP connection to RDS. Each handle is for a specific account. The params have the following options:
rds = RightAws::RdsInterface.new('xxxxxxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
{:logger => Logger.new('/tmp/x.log')}) #=> #<RightAws::RdsInterface::0xb7b3c30c>
Authorize an ingress. Params: +:cidrip+ or (+:ec2_security_group_name+ and +:ec2_security_group_owner+)
rds.authorize_db_security_group_ingress('kd3', :cidrip => '131.0.0.1/8')
{:owner_id=>"82...25",
:ec2_security_groups=>[],
:description=>"kd",
:ip_ranges=>
[{:status=>"Authorized", :cidrip=>"127.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"128.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"129.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"130.0.0.1/8"},
{:status=>"Authorizing", :cidrip=>"131.0.0.1/8"}],
:name=>"kd3"}
rds.authorize_db_security_group_ingress('kd3',:ec2_security_group_owner => '82...27',
:ec2_security_group_name => 'default') #=>
{:owner_id=>"82...25",
:ec2_security_groups=>
[{:status=>"Authorized", :owner_id=>"82...25", :name=>"g1"},
{:status=>"Authorized", :owner_id=>"82...26", :name=>"g2"},
{:status=>"Authorizing", :owner_id=>"82...27", :name=>"default"}],
:ip_ranges=>
[{:status=>"Authorized", :cidrip=>"127.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"128.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"129.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"130.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"131.0.0.1/8"}],
:name=>"kd3"}
Create a new RDS instance of the type and size specified by you. The default storage engine for RDS Instances is InnoDB.
Mandatory arguments: aws_id, master_username, master_user_password Optional params: +:allocated_storage+ (25 by def), +:instance_class+, +:engine+ (‘MySQL5.1’ by def), +:endpoint_port+, +:db_name+, +:db_security_groups+, +:db_parameter_group+, +:availability_zone+, +:preferred_maintenance_window+ +:backup_retention_period+, +:preferred_backup_window+
ds.create_db_instance('my-awesome-db', 'username', 'password') #=>
{:instance_class=>"Medium",
:status=>"creating",
:engine=>"MySQL5.1",
:allocated_storage=>50,
:pending_modified_values=>{},
:db_security_groups=>
[{:status=>"active", :name=>"kd-2-test"},
{:status=>"active", :name=>"default"},
{:status=>"active", :name=>"kd-1-test"}],
:availability_zone=>"us-east-1b",
:master_username=>"username",
:aws_id=>"kd-my-awesome-db-2",
:preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}
Creates a database parameter group so that configuration of an RDS Instance can be controlled.
rds.create_db_parameter_group('my-new-group-1','My new group') #=> {}
TODO: this call returns an empty hash, but should be a parameter group data - ask Amazon guys.
Create a database security group so that ingress to an RDS Instance can be controlled. A new security group cannot have the same name as an existing group.
ds.create_db_security_group('kd3', 'kd') #=>
{:ec2_security_groups=>[],
:description=>"kd",
:ip_ranges=>[],
:name=>"kd3",
:owner_id=>"82...25"}
Create a DBSnapshot. The source DBInstance must be in Available state
rds.create_db_snapshot('remove-me-tomorrow-2', 'my-awesome-db-g7' ) #=>
{:status=>"PendingCreation",
:allocated_storage=>50,
:availability_zone=>"us-east-1b",
:engine=>"MySQL5.1",
:aws_id=>"remove-me-tomorrow-2",
:instance_create_time=>"2009-07-13T09:35:39.243Z",
:endpoint_port=>3306,
:instance_aws_id=>"my-awesome-db-g7",
:db_master_username=>"username"}
Delete a DB instance
Mandatory arguments: aws_id Optional params: :skip_final_snapshot (‘false’ by def),
:snapshot_aws_id ('{instance_aws_id}-final-snapshot-YYYYMMDDHHMMSS')
rds.delete_db_instance('my-awesome-db-g2') #=> true
Delete a database security group. Database security group must not be associated with any RDS Instances.
rds.delete_db_security_group('kd3') #=> true
Delete a DBSnapshot. The DBSnapshot must be in the Available state to be deleted.
rds.delete_db_snapshot('remove-me-tomorrow-1') #=>
{:status=>"Deleted",
:allocated_storage=>50,
:instance_create_time=>"2009-07-13T09:27:01.053Z",
:availability_zone=>"us-east-1a",
:db_master_username=>"username",
:aws_id=>"remove-me-tomorrow-1",
:snapshot_time=>"2009-07-13T10:59:30.227Z",
:endpoint_port=>3306,
:instance_aws_id=>"my-awesome-db-g5",
:engine=>"MySQL5.1"}
List DB instances.
Optional params: +:aws_id+, +:max_records+, +:marker+
# Get a list of DB instances. The response is an +Array+ of instances.
rds.describe_db_instances #=>
[{:instance_class=>"Medium",
:status=>"creating",
:engine=>"MySQL5.1",
:allocated_storage=>50,
:pending_modified_values=>{},
:db_parameter_group=>{:status=>"in-sync", :name=>"default.MySQL5.1"},
:db_security_groups=>
[{:status=>"active", :name=>"kd-2-test"},
{:status=>"active", :name=>"default"},
{:status=>"active", :name=>"kd-1-test"}],
:availability_zone=>"us-east-1b",
:master_username=>"username",
:aws_id=>"kd-my-awesome-db-2",
:preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}]
# Retrieve a custom DB instance.
# The response is an +Array+ with a single instance record.
rds.describe_db_instances("kd-test-n3")
# Incrementally a list DB instances. Every response part is a +Hash+.
rds.describe_db_instances(:max_records => 30) do |x|
puts x.inspect #=>
{:db_instances=>
[{:instance_class=>"Medium",
:status=>"creating",
:engine=>"MySQL5.1",
:allocated_storage=>50,
:pending_modified_values=>{},
:db_parameter_group=>{:status=>"in-sync", :name=>"default.MySQL5.1"},
:db_security_groups=>
[{:status=>"active", :name=>"kd-2-test"},
{:status=>"active", :name=>"default"},
{:status=>"active", :name=>"kd-1-test"}],
:availability_zone=>"us-east-1b",
:master_username=>"username",
:aws_id=>"kd-my-awesome-db-2",
:preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}]}
true
end
Describe DBParameterGroups.
rds.describe_db_parameter_groups #=>
[{:engine=>"MySQL5.1",
:description=>"Default parameter group for MySQL5.1",
:name=>"default.MySQL5.1"}]
# List parameter groups by 20
rds.describe_db_parameter_groups(:max_records=>20) do |response|
puts response.inspect
true
end
Get the detailed parameters list for a particular DBParameterGroup.
rds.describe_db_parameters('kd1') #=>
[{:is_modifiable=>true,
:apply_type=>"static",
:source=>"engine-default",
:allowed_values=>"ON,OFF",
:description=>"Controls whether user-defined functions that have only an xxx symbol for the main function can be loaded",
:name=>"allow-suspicious-udfs",
:data_type=>"boolean"},
{:is_modifiable=>true,
:apply_type=>"dynamic",
:source=>"engine-default",
:allowed_values=>"1-65535",
:description=>"Intended for use with master-to-master replication, and can be used to control the operation of AUTO_INCREMENT columns",
:name=>"auto_increment_increment",
:data_type=>"integer"}, ... ]
# List parameters by 20
rds.describe_db_parameters('kd1', :max_records=>20) do |response|
puts response.inspect
true
end
DB SecurityGroups
rds.describe_db_security_groups #=>
[{:owner_id=>"82...25",
:description=>"Default",
:ec2_security_groups=>[],
:ip_ranges=>[],
:name=>"Default"},
{:owner_id=>"82...25",
:description=>"kd",
:ec2_security_groups=>[],
:ip_ranges=>[],
:name=>"kd2"},
{:owner_id=>"82...25",
:description=>"kd",
:ec2_security_groups=>
[{:status=>"Authorized", :owner_id=>"82...23", :name=>"default"},
{:status=>"Authorized", :owner_id=>"82...24", :name=>"default1"},
{:status=>"Authorized", :owner_id=>"82...25", :name=>"default"},
{:status=>"Authorized", :owner_id=>"82...26", :name=>"default"},
{:status=>"Authorized", :owner_id=>"82...26", :name=>"default1"},
{:status=>"Authorized", :owner_id=>"82...29", :name=>"default22"}],
:ip_ranges=>
[{:status=>"Authorized", :cidrip=>"127.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"128.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"129.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"130.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"131.0.0.1/8"}],
:name=>"kd3"}]
# get a custom group
rds.describe_db_security_groups('kd3')
Get DBSecurityGroup details for a particular customer or for a particular DBSecurityGroup if a name is specified. Optional params: +:instance_aws_id+
# all snapshots
rds.describe_db_snapshots #=>
[{:status=>"Available",
:instance_aws_id=>"kd-test-n1",
:allocated_storage=>25,
:availability_zone=>"us-east-1b",
:aws_id=>"kd-test-n1-final-snapshot-at-20090630131215",
:engine=>"MySQL5.1",
:endpoint_port=>3306,
:instance_create_time=>"2009-06-30T12:48:15.590Z",
:master_username=>"payless",
:snapshot_time=>"2009-06-30T13:16:48.496Z"}, ...]
# all snapshots for a custom instance
rds.describe_db_snapshots(:instance_aws_id => 'kd-test-n3') #=>
[{:status=>"Available",
:instance_aws_id=>"kd-test-n3",
:allocated_storage=>25,
:availability_zone=>"us-east-1a",
:aws_id=>"kd-test-n3-final-snapshot-20090713074916",
:engine=>"MySQL5.1",
:endpoint_port=>3306,
:instance_create_time=>"2009-06-30T12:51:32.540Z",
:master_username=>"payless",
:snapshot_time=>"2009-07-13T07:52:35.542Z"}]
# a snapshot by id
rds.describe_db_snapshots('my-awesome-db-final-snapshot-20090713075554') #=>
[{:status=>"Available",
:allocated_storage=>25,
:engine=>"MySQL5.1",
:instance_aws_id=>"my-awesome-db",
:availability_zone=>"us-east-1a",
:instance_create_time=>"2009-07-13T07:53:08.912Z",
:endpoint_port=>3306,
:master_username=>"medium",
:aws_id=>"my-awesome-db-final-snapshot-20090713075554",
:snapshot_time=>"2009-07-13T07:59:17.537Z"}]
Describe a default parameters for the engine.
rds.describe_engine_default_parameters('MySQL5.1') #=>
[{:is_modifiable=>true,
:apply_type=>"static",
:source=>"engine-default",
:allowed_values=>"ON,OFF",
:description=>"Controls whether user-defined functions that have only an xxx symbol for the main function can be loaded",
:name=>"allow-suspicious-udfs",
:data_type=>"boolean"},
{:is_modifiable=>true,
:apply_type=>"dynamic",
:source=>"engine-default",
:allowed_values=>"1-65535",
:description=>"Intended for use with master-to-master replication, and can be used to control the operation of AUTO_INCREMENT columns",
:name=>"auto_increment_increment",
:data_type=>"integer"}, ... ]
Get events related to RDS instances and DBSecurityGroups for the past 14 days. Optional params: +:duration+, +:start_time+, +:end_time+, +:aws_id+,
+:source_type+('db-instance', 'db-security-group', 'db-snapshot', 'db-parameter-group')
# get all enevts
rds.describe_events #=>
[{:aws_id=>"my-awesome-db-g4",
:source_type=>"DBInstance",
:message=>"Started user snapshot for database instance:my-awesome-db-g4",
:date=>"2009-07-13T10:54:13.661Z"},
{:aws_id=>"my-awesome-db-g5",
:source_type=>"DBInstance",
:message=>"Started user snapshot for database instance:my-awesome-db-g5",
:date=>"2009-07-13T10:55:13.674Z"},
{:aws_id=>"my-awesome-db-g7",
:source_type=>"DBInstance",
:message=>"Started user snapshot for database instance:my-awesome-db-g7",
:date=>"2009-07-13T10:56:34.226Z"}]
# get all events since yesterday
rds.describe_events(:start_date => 1.day.ago)
# get last 60 min events
rds.describe_events(:duration => 60)
Modify a DB instance.
Mandatory arguments: aws_id. Optional params: +:master_user_password+, +:instance_class+, +:db_security_groups+, +:db_parameter_group+, +:preferred_maintenance_window+, +:allocated_storage+, +:apply_immediately+, +:backup_retention_period+, +:preferred_backup_window+
Reboot Db instance.
rds.reboot_db_instance('kd-my-awesome-db') #=>
{:status=>"rebooting",
:pending_modified_values=>{},
:allocated_storage=>42,
:master_username=>"kd",
:db_security_groups=>[],
:instance_class=>"Medium",
:availability_zone=>"us-east-1a",
:aws_id=>"kd-my-awesome-db",
:create_time=>"2009-08-28T08:34:21.858Z",
:engine=>"MySQL5.1",
:preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}
Modify the parameters of a DBParameterGroup to the engine/system default value.
# Reset all parameters
rds.reset_db_parameter_group('kd2', :all ) #=> true
# Reset custom parameters
rds.reset_db_parameter_group('kd2', 'max_allowed_packet', 'auto_increment_increment' ) #=> true
rds.reset_db_parameter_group('kd2', 'max_allowed_packet', 'auto_increment_increment' => 'immediate' ) #=> true
Create a new RDS instance from a DBSnapshot. The source DBSnapshot must be in the "Available" state. The new RDS instance is created with the Default security group.
Optional params: +:instance_class+, +:endpoint_port+, +:availability_zone+
rds.restore_db_instance_from_db_snapshot('ahahahaha-final-snapshot-20090828081159', 'q1') #=>
{:status=>"creating",
:pending_modified_values=>{},
:allocated_storage=>42,
:db_security_groups=>[],
:master_username=>"kd",
:availability_zone=>"us-east-1a",
:aws_id=>"q1",
:create_time=>"2009-08-29T18:07:01.510Z",
:instance_class=>"Medium",
:preferred_maintenance_window=>"Sun:05:00-Sun:09:00",
:engine=>"MySQL5.1"}
Revoke an ingress. Optional params: +:cidrip+ or (+:ec2_security_group_name+ and +:ec2_security_group_owner+)
rds.revoke_db_security_group_ingress('kd3', :ec2_security_group_owner => '82...25',
:ec2_security_group_name => 'default') #=>
{:owner_id=>"82...25",
:ec2_security_groups=>
[{:status=>"Revoking", :owner_id=>"826693181925", :name=>"default"}],
:name=>"kd3",
:description=>"kd",
:ip_ranges=>
[{:status=>"Authorized", :cidrip=>"127.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"128.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"129.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"130.0.0.1/8"},
{:status=>"Authorized", :cidrip=>"131.0.0.1/8"}]}