| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | import pytest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import boto3 | 
					
						
							|  |  |  | from botocore.exceptions import ClientError | 
					
						
							| 
									
										
										
										
											2021-10-18 19:44:29 +00:00
										 |  |  | import sure  # noqa # pylint: disable=unused-import | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-18 19:44:29 +00:00
										 |  |  | from moto import mock_ec2, mock_iam | 
					
						
							| 
									
										
										
										
											2021-01-13 09:02:11 +00:00
										 |  |  | from tests import EXAMPLE_AMI_ID | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  | from uuid import uuid4 | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def quick_instance_creation(): | 
					
						
							|  |  |  |     conn_ec2 = boto3.resource("ec2", "us-east-1") | 
					
						
							| 
									
										
										
										
											2021-01-13 09:02:11 +00:00
										 |  |  |     test_instance = conn_ec2.create_instances( | 
					
						
							|  |  |  |         ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1 | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     # We only need instance id for this tests | 
					
						
							|  |  |  |     return test_instance[0].id | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def quick_instance_profile_creation(name): | 
					
						
							|  |  |  |     conn_iam = boto3.resource("iam", "us-east-1") | 
					
						
							|  |  |  |     test_instance_profile = conn_iam.create_instance_profile( | 
					
						
							|  |  |  |         InstanceProfileName=name, Path="/" | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     return test_instance_profile.arn, test_instance_profile.name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_associate(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  |     instance_id = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn, instance_profile_name = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     association = client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							|  |  |  |             "Arn": instance_profile_arn, | 
					
						
							|  |  |  |             "Name": instance_profile_name, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         InstanceId=instance_id, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     association["IamInstanceProfileAssociation"]["InstanceId"].should.equal(instance_id) | 
					
						
							|  |  |  |     association["IamInstanceProfileAssociation"]["IamInstanceProfile"][ | 
					
						
							|  |  |  |         "Arn" | 
					
						
							|  |  |  |     ].should.equal(instance_profile_arn) | 
					
						
							|  |  |  |     association["IamInstanceProfileAssociation"]["State"].should.equal("associating") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_invalid_associate(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  |     instance_id = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn, instance_profile_name = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							|  |  |  |             "Arn": instance_profile_arn, | 
					
						
							|  |  |  |             "Name": instance_profile_name, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         InstanceId=instance_id, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Duplicate | 
					
						
							|  |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         client.associate_iam_instance_profile( | 
					
						
							|  |  |  |             IamInstanceProfile={ | 
					
						
							|  |  |  |                 "Arn": instance_profile_arn, | 
					
						
							|  |  |  |                 "Name": instance_profile_name, | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             InstanceId=instance_id, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ex.value.response["Error"]["Code"].should.equal("IncorrectState") | 
					
						
							|  |  |  |     ex.value.response["Error"]["Message"].should.contain( | 
					
						
							|  |  |  |         "There is an existing association for" | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Wrong instance profile | 
					
						
							|  |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         client.associate_iam_instance_profile( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |             IamInstanceProfile={"Arn": "fake", "Name": "fake"}, InstanceId=instance_id | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |         ) | 
					
						
							|  |  |  |     ex.value.response["Error"]["Code"].should.equal("NoSuchEntity") | 
					
						
							|  |  |  |     ex.value.response["Error"]["Message"].should.contain("not found") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Wrong instance id | 
					
						
							|  |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         client.associate_iam_instance_profile( | 
					
						
							|  |  |  |             IamInstanceProfile={ | 
					
						
							|  |  |  |                 "Arn": instance_profile_arn, | 
					
						
							|  |  |  |                 "Name": instance_profile_name, | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             InstanceId="fake", | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ex.value.response["Error"]["Code"].should.equal("InvalidInstanceID.NotFound") | 
					
						
							|  |  |  |     ex.value.response["Error"]["Message"].should.contain("does not exist") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_describe(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     instance_id1 = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn1, instance_profile_name1 = quick_instance_profile_creation( | 
					
						
							|  |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |             "Arn": instance_profile_arn1, | 
					
						
							|  |  |  |             "Name": instance_profile_name1, | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         InstanceId=instance_id1, | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     associations = client.describe_iam_instance_profile_associations() | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     associations = associations["IamInstanceProfileAssociations"] | 
					
						
							|  |  |  |     [a["IamInstanceProfile"]["Arn"] for a in associations].should.contain( | 
					
						
							|  |  |  |         instance_profile_arn1 | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     my_assoc = [ | 
					
						
							|  |  |  |         a | 
					
						
							|  |  |  |         for a in associations | 
					
						
							|  |  |  |         if a["IamInstanceProfile"]["Arn"] == instance_profile_arn1 | 
					
						
							|  |  |  |     ][0] | 
					
						
							|  |  |  |     my_assoc["InstanceId"].should.equal(instance_id1) | 
					
						
							|  |  |  |     my_assoc["State"].should.equal("associated") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     instance_id2 = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn2, instance_profile_name2 = quick_instance_profile_creation( | 
					
						
							|  |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |             "Arn": instance_profile_arn2, | 
					
						
							|  |  |  |             "Name": instance_profile_name2, | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         InstanceId=instance_id2, | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     associations = client.describe_iam_instance_profile_associations() | 
					
						
							|  |  |  |     associations = associations["IamInstanceProfileAssociations"] | 
					
						
							|  |  |  |     [a["IamInstanceProfile"]["Arn"] for a in associations].should.contain( | 
					
						
							|  |  |  |         instance_profile_arn1 | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     [a["IamInstanceProfile"]["Arn"] for a in associations].should.contain( | 
					
						
							|  |  |  |         instance_profile_arn2 | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     my_assoc = [ | 
					
						
							|  |  |  |         a | 
					
						
							|  |  |  |         for a in associations | 
					
						
							|  |  |  |         if a["IamInstanceProfile"]["Arn"] == instance_profile_arn1 | 
					
						
							|  |  |  |     ][0] | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     associations = client.describe_iam_instance_profile_associations( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         AssociationIds=[my_assoc["AssociationId"]] | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     associations["IamInstanceProfileAssociations"].should.have.length_of(1) | 
					
						
							|  |  |  |     associations["IamInstanceProfileAssociations"][0]["IamInstanceProfile"][ | 
					
						
							|  |  |  |         "Arn" | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     ].should.equal(my_assoc["IamInstanceProfile"]["Arn"]) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     associations = client.describe_iam_instance_profile_associations( | 
					
						
							|  |  |  |         Filters=[ | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |             {"Name": "instance-id", "Values": [my_assoc["InstanceId"]]}, | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |             {"Name": "state", "Values": ["associated"]}, | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     associations["IamInstanceProfileAssociations"].should.have.length_of(1) | 
					
						
							|  |  |  |     associations["IamInstanceProfileAssociations"][0]["IamInstanceProfile"][ | 
					
						
							|  |  |  |         "Arn" | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     ].should.equal(my_assoc["IamInstanceProfile"]["Arn"]) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_replace(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  |     instance_id1 = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn1, instance_profile_name1 = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     instance_profile_arn2, instance_profile_name2 = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     association = client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							|  |  |  |             "Arn": instance_profile_arn1, | 
					
						
							|  |  |  |             "Name": instance_profile_name1, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         InstanceId=instance_id1, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     association = client.replace_iam_instance_profile_association( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							|  |  |  |             "Arn": instance_profile_arn2, | 
					
						
							|  |  |  |             "Name": instance_profile_name2, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         AssociationId=association["IamInstanceProfileAssociation"]["AssociationId"], | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     association["IamInstanceProfileAssociation"]["IamInstanceProfile"][ | 
					
						
							|  |  |  |         "Arn" | 
					
						
							|  |  |  |     ].should.equal(instance_profile_arn2) | 
					
						
							|  |  |  |     association["IamInstanceProfileAssociation"]["State"].should.equal("associating") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_invalid_replace(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  |     instance_id = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn, instance_profile_name = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     instance_profile_arn2, instance_profile_name2 = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     association = client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							|  |  |  |             "Arn": instance_profile_arn, | 
					
						
							|  |  |  |             "Name": instance_profile_name, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         InstanceId=instance_id, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Wrong id | 
					
						
							|  |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         client.replace_iam_instance_profile_association( | 
					
						
							|  |  |  |             IamInstanceProfile={ | 
					
						
							|  |  |  |                 "Arn": instance_profile_arn2, | 
					
						
							|  |  |  |                 "Name": instance_profile_name2, | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             AssociationId="fake", | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ex.value.response["Error"]["Code"].should.equal("InvalidAssociationID.NotFound") | 
					
						
							|  |  |  |     ex.value.response["Error"]["Message"].should.contain("An invalid association-id of") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Wrong instance profile | 
					
						
							|  |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         client.replace_iam_instance_profile_association( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |             IamInstanceProfile={"Arn": "fake", "Name": "fake"}, | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |             AssociationId=association["IamInstanceProfileAssociation"]["AssociationId"], | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ex.value.response["Error"]["Code"].should.equal("NoSuchEntity") | 
					
						
							|  |  |  |     ex.value.response["Error"]["Message"].should.contain("not found") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_disassociate(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  |     instance_id = quick_instance_creation() | 
					
						
							|  |  |  |     instance_profile_arn, instance_profile_name = quick_instance_profile_creation( | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |         str(uuid4()) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     association = client.associate_iam_instance_profile( | 
					
						
							|  |  |  |         IamInstanceProfile={ | 
					
						
							|  |  |  |             "Arn": instance_profile_arn, | 
					
						
							|  |  |  |             "Name": instance_profile_name, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         InstanceId=instance_id, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     associations = client.describe_iam_instance_profile_associations() | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     associations = associations["IamInstanceProfileAssociations"] | 
					
						
							|  |  |  |     [a["IamInstanceProfile"]["Arn"] for a in associations].should.contain( | 
					
						
							|  |  |  |         instance_profile_arn | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     disassociation = client.disassociate_iam_instance_profile( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         AssociationId=association["IamInstanceProfileAssociation"]["AssociationId"] | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     disassociation["IamInstanceProfileAssociation"]["IamInstanceProfile"][ | 
					
						
							|  |  |  |         "Arn" | 
					
						
							|  |  |  |     ].should.equal(instance_profile_arn) | 
					
						
							|  |  |  |     disassociation["IamInstanceProfileAssociation"]["State"].should.equal( | 
					
						
							|  |  |  |         "disassociating" | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     associations = client.describe_iam_instance_profile_associations() | 
					
						
							| 
									
										
										
										
											2021-10-05 17:11:07 +00:00
										 |  |  |     associations = associations["IamInstanceProfileAssociations"] | 
					
						
							|  |  |  |     [a["IamInstanceProfile"]["Arn"] for a in associations].shouldnt.contain( | 
					
						
							|  |  |  |         instance_profile_arn | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_ec2 | 
					
						
							|  |  |  | @mock_iam | 
					
						
							|  |  |  | def test_invalid_disassociate(): | 
					
						
							|  |  |  |     client = boto3.client("ec2", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Wrong id | 
					
						
							|  |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         client.disassociate_iam_instance_profile(AssociationId="fake") | 
					
						
							| 
									
										
										
										
											2020-11-20 23:00:53 +01:00
										 |  |  |     ex.value.response["Error"]["Code"].should.equal("InvalidAssociationID.NotFound") | 
					
						
							|  |  |  |     ex.value.response["Error"]["Message"].should.contain("An invalid association-id of") |