Repository: getmoto/moto

Issue:
Potential bug? create image in ec2 mocking, but the owner id of this imaged returned error 
Here is my code to mock creating AMI in ec2:

```
@mock_ec2_deprecated
@mock_iam_deprecated
def test_images(self):
    conn = boto.ec2.connect_to_region(CLOUD_REGION,
                                      aws_access_key_id=access_key,
                                      aws_secret_access_key=secret_key)
    reservation = conn.run_instances("ami-1234abcd")
    instance = reservation.instances[0]
    image_id = conn.create_image(instance.id, "test-ami", "this is a test ami")
    amis = conn.get_all_images()
    for ami in amis:
         print ami.id, ami.owner_id
```

Then i found that owner id of image i just created return access key instead of account id.
Am I doing something wrong?


Discussion:

Resolving patch:
diff --git a/moto/ec2/models.py b/moto/ec2/models.py
--- a/moto/ec2/models.py
+++ b/moto/ec2/models.py
@@ -27,6 +27,7 @@
     iso_8601_datetime_with_milliseconds,
     camelcase_to_underscores,
 )
+from moto.iam.models import ACCOUNT_ID
 from .exceptions import (
     CidrLimitExceeded,
     DependencyViolationError,
@@ -155,7 +156,7 @@ def _load_resource(filename):
 )
 
 
-OWNER_ID = "111122223333"
+OWNER_ID = ACCOUNT_ID
 
 
 def utc_date_and_time():
@@ -1341,7 +1342,7 @@ def create_image(self, instance_id, name=None, description=None, context=None):
             source_ami=None,
             name=name,
             description=description,
-            owner_id=context.get_current_user() if context else OWNER_ID,
+            owner_id=OWNER_ID,
         )
         self.amis[ami_id] = ami
         return ami
@@ -1392,14 +1393,7 @@ def describe_images(
             # Limit by owner ids
             if owners:
                 # support filtering by Owners=['self']
-                owners = list(
-                    map(
-                        lambda o: context.get_current_user()
-                        if context and o == "self"
-                        else o,
-                        owners,
-                    )
-                )
+                owners = list(map(lambda o: OWNER_ID if o == "self" else o, owners,))
                 images = [ami for ami in images if ami.owner_id in owners]
 
             # Generic filters


Test patch:
diff --git a/tests/test_ec2/test_amis.py b/tests/test_ec2/test_amis.py
--- a/tests/test_ec2/test_amis.py
+++ b/tests/test_ec2/test_amis.py
@@ -12,6 +12,7 @@
 
 from moto import mock_ec2_deprecated, mock_ec2
 from moto.ec2.models import AMIS, OWNER_ID
+from moto.iam.models import ACCOUNT_ID
 from tests.helpers import requires_boto_gte
 
 
@@ -251,6 +252,19 @@ def test_ami_pulls_attributes_from_instance():
     image.kernel_id.should.equal("test-kernel")
 
 
+@mock_ec2_deprecated
+def test_ami_uses_account_id_if_valid_access_key_is_supplied():
+    access_key = "AKIAXXXXXXXXXXXXXXXX"
+    conn = boto.connect_ec2(access_key, "the_secret")
+    reservation = conn.run_instances("ami-1234abcd")
+    instance = reservation.instances[0]
+    instance.modify_attribute("kernel", "test-kernel")
+
+    image_id = conn.create_image(instance.id, "test-ami", "this is a test ami")
+    images = conn.get_all_images(owners=["self"])
+    [(ami.id, ami.owner_id) for ami in images].should.equal([(image_id, ACCOUNT_ID)])
+
+
 @mock_ec2_deprecated
 def test_ami_filters():
     conn = boto.connect_ec2("the_key", "the_secret")
@@ -773,7 +787,7 @@ def test_ami_filter_wildcard():
     instance.create_image(Name="not-matching-image")
 
     my_images = ec2_client.describe_images(
-        Owners=["111122223333"], Filters=[{"Name": "name", "Values": ["test*"]}]
+        Owners=[ACCOUNT_ID], Filters=[{"Name": "name", "Values": ["test*"]}]
     )["Images"]
     my_images.should.have.length_of(1)