diff --git a/moto/iam/models.py b/moto/iam/models.py index 60b9b743d..d27722f33 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -501,6 +501,8 @@ class IAMBackend(BaseBackend): if profile.name == profile_name: return profile + raise IAMNotFoundException("Instance profile {0} not found".format(profile_name)) + def get_instance_profiles(self): return self.instance_profiles.values() diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index bedea4e01..de8f89a59 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -62,6 +62,14 @@ def test_get_role__should_throw__when_role_does_not_exist(): conn.get_role('unexisting_role') +@mock_iam() +@raises(BotoServerError) +def test_get_instance_profile__should_throw__when_instance_profile_does_not_exist(): + conn = boto.connect_iam() + + conn.get_instance_profile('unexisting_instance_profile') + + @mock_iam() def test_create_role_and_instance_profile(): conn = boto.connect_iam()