Q: Moto warning: Use ec2_backend.describe_images() to find suitable image for your test I'm trying to test a function that uploads a cloud formation using create_stack() from boto3.
For the test I'm using the framework moto.
For the test I create a template_data in yaml with a pytest fixture:
@pytest.fixture(scope='function')
def template_body_data():
    'The Cloud Formation template'
    template_data = {
        'Resources': {
            'MyInstance': {
                'Type': 'AWS::EC2::Instance',
                'Properties': {'ImageId': 'ami-a4c7edb2', 'InstanceType': 't2.micro'},
            }
        }
    }
    return template_data

All my tests works.
The problem is that I get this warning:
/home/myprofile/.cache/pypoetry/virtualenvs/cl-uploader-12nYBdPj-py3.8/lib/python3.8/site-packages/moto/ec2/models.py:517: PendingDeprecationWarning: Could not find AMI with image-id:ami-a4c7edb2, in the near future this will cause an error.
  Use ec2_backend.describe_images() to find suitable image for your test

How can I fix this?

A: Use the image id from third step below and it would resolve the warning
client = boto3.client('ec2', aws_region)
image_response = client.describe_images()
image_id = image_response['Images'][0]['ImageId']

