Can't get list of instances with RdsInterface #73

Closed
cbailster opened this Issue Jun 22, 2011 · 7 comments

Comments

Projects
None yet
3 participants

When using RdsInterfaces describe_db_instance method you get the following error when using right_aws 2.1.0:

RightAws::AwsError: InvalidParameterValue: The parameter DBInstanceIdentifier is not a valid identifier

This is because AwsUtils::split_items_and_params(params) returns an array of items, not a string, and so the URL request to AWS is constructed incorrectly.

Suggested fix:

    def describe_db_instances(*params, &block)
      item, params = AwsUtils::split_items_and_params(params)
      params = params.dup
      params['DBInstanceIdentifier'] = item[0] if item[0]
      incrementally_list_items('DescribeDBInstances', DescribeDbInstancesParser, params) do |response|
        result += response[:db_instances]
        block ? block.call(response) : true
      end
      result
    end
Contributor

konstantin-dzreev commented Jun 22, 2011

Are you passing an array of names or just a single RDS instance name? If you do it like:

rds.describe_db_instances('my-rds-instance')

it should work fine because we do "to_s" before sending it.

Can you plz post your code that fails?

Thanks

I'm not passing an instance name, but have just tried it and it gives the same error:

rds = RightAws::RdsInterface.new(xxxxxxx, yyyyyyyy, :server => 'rds.eu-west-1.amazonaws.com')
rds.get_db_instances('my-instance-name')
RightAws::AwsError: InvalidParameterValue: The parameter DBInstanceIdentifier is not a valid identifier. Identifiers must begin with a letter; must contain only ASCII letters, digits, and hyphens; and must not end with a hyphen or contain two consecutive hyphens.

Aah, hang on I think I know what's going on here. I'm using Ruby 1.9.2. Array.to_s changed between 1.8.7 and 1.9.2

in 1.8.7

    => "hello"

in 1.9.2

    => "[\"hello\"]"

In 1.8.7 Array.to_s is effectively Array.join, whereas in 1.9.2 Array.to_s returns the same as Array.inspect

Contributor

konstantin-dzreev commented Jun 22, 2011

ah, I see now

I'll fix this, thank you!

P.S. btw if you need to debug things you can use something like this:

begin
rds.describe_db_instances('my-instance-name')
rescue
puts rds.last_request.path
if rds.last_response
puts rds.last_response.body
puts rds.last_response.to_hash.inspect
end

etc

end

Contributor

konstantin-dzreev commented Jun 22, 2011

can you plz pull and give it a try?

But be careful: we have switched to the next RDS API 2011-04-01.

Just tested with new version. Looks like the change has fixed the problem I was seeing.

Thanks for the quick resolution.

@cbailster cbailster closed this Jun 22, 2011

kidbrax commented Oct 6, 2011

So to get this fix, we have pull from the github version? it is not in the released gem on rubygems, correct?

klochner pushed a commit to LeaseStar/right_aws that referenced this issue Oct 12, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment