diff --git a/moto/ec2/models.py b/moto/ec2/models.py index f90ceae9f..e3342c8c8 100755 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -632,6 +632,8 @@ class InstanceBackend(object): def terminate_instances(self, instance_ids): terminated_instances = [] + if not instance_ids: + raise EC2ClientError("InvalidParameterCombination", "No instances specified") for instance in self.get_multi_instances_by_id(instance_ids): instance.terminate() terminated_instances.append(instance) diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py index 58b1f693a..e3959d8e0 100644 --- a/tests/test_ec2/test_instances.py +++ b/tests/test_ec2/test_instances.py @@ -73,6 +73,13 @@ def test_instance_launch_and_terminate(): instance = reservations[0].instances[0] instance.state.should.equal('terminated') + +@mock_ec2 +def test_terminate_empty_instances(): + conn = boto.connect_ec2('the_key', 'the_secret') + conn.terminate_instances.when.called_with([]).should.throw(EC2ResponseError) + + @freeze_time("2014-01-01 05:00:00") @mock_ec2 def test_instance_attach_volume(): @@ -330,6 +337,7 @@ def test_get_instances_filtering_by_tag(): reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance3.id) + @mock_ec2 def test_get_instances_filtering_by_tag_value(): conn = boto.connect_ec2()