Skip to content

Commit

Permalink
Add StateTransitionReason to ec2:DescribeInstances response (#7495)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpandola authored Mar 19, 2024
1 parent 009d019 commit 3e90012
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion moto/ec2/responses/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def _convert_to_bool(bool_str: Any) -> bool: # type: ignore[misc]
<privateDnsName>{{ instance.private_dns }}</privateDnsName>
<publicDnsName>{{ instance.public_dns }}</publicDnsName>
<dnsName>{{ instance.public_dns }}</dnsName>
<reason/>
<reason>{{ instance._reason }}</reason>
{% if instance.key_name is not none %}
<keyName>{{ instance.key_name }}</keyName>
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions tests/test_ec2/test_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ def test_instance_start_and_stop():

instance1.reload()
assert instance1.state == {"Code": 80, "Name": "stopped"}
assert instance1.state_transition_reason.startswith("User initiated")

with pytest.raises(ClientError) as ex:
client.start_instances(InstanceIds=[instance1.id], DryRun=True)
Expand Down

0 comments on commit 3e90012

Please sign in to comment.