aws/aws-sdk-ruby

Aws::EC2::Resources raises `InvalidParameterCombination` when some parameters are specified

Closed this issue · 2 comments

Describe the bug

Some AWS APIs are not allowed to use MaxResults parameter.

But aws-sdk-ec2 >= 1.448.1 automatically sets max_results.

For that reason, Aws::EC2::Errors::InvalidParameterCombination will be raised some parameter conditions.

AFIK, the following parameters are not allowed to use MaxResults simultaneously.

Aws::EC2::Resources#images

  • ImageId.N

Aws::EC2::Resources#instances

You cannot specify this parameter and the instance IDs parameter in the same request.

  • InstanceId.N

Aws::EC2::Resources#snapshots

You cannot specify this parameter and the snapshot IDs parameter in the same request.

  • SnapshotId.N

Aws::EC2::Resources#volumes

You cannot specify this parameter and the volume IDs parameter in the same request.

  • VolumeId.N

Expected Behavior

Aws::EC2::Resources does not set max_results automatically when the given options contains the parameter which cannot be used with max_results in the same request.

Current Behavior

Aws::EC2::Resources setsmax_results automatically even if the given options contains the parameter which cannot be used with max_results in the same request.

Reproduction Steps

Use aws-sdk-ec2 >= 1.448.1

Raises Aws::EC2::Errors::InvalidParameterCombination

require "aws-sdk-ec2"

ec2 = Aws::EC2::Resource.new
ec2.images(
  owners: ["self"],
  image_ids: %w[ami-1234567890abc],  # whatever the value
).to_a

# raises The parameter imageIdsSet cannot be used with the parameter maxResults (Aws::EC2::Errors::InvalidParameterCombination)

Dose not raise Aws::EC2::Errors::InvalidParameterCombination

require "aws-sdk-ec2"

ec2 = Aws::EC2::Resource.new
ec2.images(
  owners: ["self"],
).to_a

Possible Solution

Do not set max_results if the options contains parameter which cannot be used with max_results.

Additional Information/Context

No response

Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version

aws-sdk-ec2

Environment details (Version of Ruby, OS environment)

Ruby >= 2.7, aws-sdk-ec2 >= 1.448.1

Hey sorry you are running into this and thank you for submitting a PR - I'm reviewing and trying to confirm a complete list of incompatible parameters.

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.