moto
moto copied to clipboard
EbsInstanceBlockDevice has invalid status field
Hey,
According to the docs, the possible valid value for the status field in EbsInstanceBlockDevice is one of attaching | attached | detaching | detached.
Using describe_instances in Moto (v5.1.18) returns in-use for the EBS status field:
with moto.mock_aws():
import boto3
client = boto3.client('ec2')
vpc_response = client.create_vpc(CidrBlock="10.0.0.0/16")
vpc_id = vpc_response["Vpc"]["VpcId"]
subnet_response = client.create_subnet(VpcId=vpc_id, CidrBlock="10.0.0.0/24")
subnet_id = subnet_response["Subnet"]["SubnetId"]
instances_response = client.run_instances(
ImageId='ami-00000000',
MinCount=2,
MaxCount=2,
InstanceType='t2.micro',
SubnetId=subnet_id
)
response = client.describe_instances()
for reservation in response['Reservations']:
for instance in reservation['Instances']:
# This will print `in-use`, instead of `attached`
print(instance['BlockDeviceMappings'][0]['Ebs']['Status'])
Seems like in-use is only valid for the Volume response.
Thanks for raising this @sallaigy, and welcome to Moto! Marking this as a bug.