You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the intended behaviour of the combination of ec2.describe_instances(...), ec2.associate_iam_instance_profile() and ec2.disassociate_iam_instance_profile(...)? Currently it's trivial to create an inconsistent state between these methods in moto.
Prior to #5617 the IamInstanceProfile was not linked to an ec2.models.instances.Instance, so describe_instances would never return an EC2 instance with the field IamInstanceProfile. That PR added logic to update the EC2 Instance attributes in the constructor of an IamInstanceProfileAssociation - but the EC2 instance is not updated again if the IamInstanceProfileAssociation is removed.
Is this a bug in moto, or intended behavior? If a bug, would it be amendable to a PR?
Background, if that's interesting/useful
I recently encountered an old test using moto@4.0.1 and have been working to upgrade it to the latest (5.0.28 as I write this).
One of the test cases uses an IamInstanceProfileAssociation, and calls iam_client.disassociate_iam_instance_profile(...) before making an assertion on the IamInstanceProfile key of the related EC2 instance.
The test passes by accident in moto>=4.0.1,<4.0.9. Prior to 4.0.9 the instance profile was never linked into the set of ec2 reservations stored by moto.
The test fails with moto>=4.0.9, as feat: link instance profile with ec2 instance #5617 updates the IamInstanceProfile of the related EC2 instance when associate_iam_instance_profile is called, however it does not update after calling disassociate_iam_instance_profile
Test case to reproduce (loosely based on the test I'm trying to fix)
What is the intended behaviour of the combination of
ec2.describe_instances(...)
,ec2.associate_iam_instance_profile()
andec2.disassociate_iam_instance_profile(...)
? Currently it's trivial to create an inconsistent state between these methods inmoto
.Prior to #5617 the
IamInstanceProfile
was not linked to anec2.models.instances.Instance
, sodescribe_instances
would never return an EC2 instance with the fieldIamInstanceProfile
. That PR added logic to update the EC2 Instance attributes in the constructor of anIamInstanceProfileAssociation
- but the EC2 instance is not updated again if theIamInstanceProfileAssociation
is removed.Is this a bug in
moto
, or intended behavior? If a bug, would it be amendable to a PR?Background, if that's interesting/useful
I recently encountered an old test using
moto@4.0.1
and have been working to upgrade it to the latest (5.0.28
as I write this).One of the test cases uses an
IamInstanceProfileAssociation
, and callsiam_client.disassociate_iam_instance_profile(...)
before making an assertion on theIamInstanceProfile
key of the related EC2 instance.moto>=4.0.1,<4.0.9
. Prior to4.0.9
the instance profile was never linked into the set of ec2 reservations stored bymoto
.moto>=4.0.9
, as feat: link instance profile with ec2 instance #5617 updates theIamInstanceProfile
of the related EC2 instance whenassociate_iam_instance_profile
is called, however it does not update after callingdisassociate_iam_instance_profile
Test case to reproduce (loosely based on the test I'm trying to fix)
details for fixture setup for the test, in case that's relevant
The text was updated successfully, but these errors were encountered: