diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py
--- a/moto/ec2/responses/instances.py
+++ b/moto/ec2/responses/instances.py
@@ -5,6 +5,7 @@
     InvalidParameterCombination,
     InvalidRequest,
 )
+from moto.ec2.utils import filter_iam_instance_profiles
 
 from copy import deepcopy
 
@@ -98,20 +99,31 @@ def run_instances(self) -> str:
         if mappings:
             kwargs["block_device_mappings"] = mappings
 
+        iam_instance_profile_name = kwargs.get("iam_instance_profile_name")
+        iam_instance_profile_arn = kwargs.get("iam_instance_profile_arn")
+        if iam_instance_profile_arn or iam_instance_profile_name:
+            # Validate the profile exists, before we error_on_dryrun and add_instances
+            filter_iam_instance_profiles(
+                self.current_account,
+                iam_instance_profile_arn=iam_instance_profile_arn,
+                iam_instance_profile_name=iam_instance_profile_name,
+            )
+
         self.error_on_dryrun()
 
         new_reservation = self.ec2_backend.add_instances(
             image_id, min_count, user_data, security_group_names, **kwargs
         )
-        if kwargs.get("iam_instance_profile_name"):
+        if iam_instance_profile_name:
             self.ec2_backend.associate_iam_instance_profile(
                 instance_id=new_reservation.instances[0].id,
-                iam_instance_profile_name=kwargs.get("iam_instance_profile_name"),
+                iam_instance_profile_name=iam_instance_profile_name,
             )
-        if kwargs.get("iam_instance_profile_arn"):
+
+        if iam_instance_profile_arn:
             self.ec2_backend.associate_iam_instance_profile(
                 instance_id=new_reservation.instances[0].id,
-                iam_instance_profile_arn=kwargs.get("iam_instance_profile_arn"),
+                iam_instance_profile_arn=iam_instance_profile_arn,
             )
 
         template = self.response_template(EC2_RUN_INSTANCES)

Thanks for raising this @romanilchyshynb - that's a bug indeed. I'll submit a PR shortly to make sure this validation occurs before actually creating the instance.
diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py
--- a/tests/test_ec2/test_instances.py
+++ b/tests/test_ec2/test_instances.py
@@ -2616,6 +2616,25 @@ def test_instance_iam_instance_profile():
     assert "Id" in instance.iam_instance_profile
     assert profile["InstanceProfile"]["Arn"] == instance.iam_instance_profile["Arn"]
 
+    tag_key = str(uuid4())[0:6]
+    with pytest.raises(ClientError) as exc:
+        ec2_resource.create_instances(
+            ImageId=EXAMPLE_AMI_ID,
+            MinCount=1,
+            MaxCount=1,
+            IamInstanceProfile={"Arn": "unknown:instance:profile"},
+            TagSpecifications=[
+                {"ResourceType": "instance", "Tags": [{"Key": tag_key, "Value": "val"}]}
+            ],
+        )
+    err = exc.value.response["Error"]
+    assert err["Code"] == "NoSuchEntity"
+    assert err["Message"] == "Instance profile unknown:instance:profile not found"
+
+    ec2_client = boto3.client("ec2", "us-west-1")
+    filters = [{"Name": "tag-key", "Values": [tag_key]}]
+    assert retrieve_all_instances(ec2_client, filters) == []
+
 
 def retrieve_all_reservations(client, filters=[]):  # pylint: disable=W0102
     resp = client.describe_instances(Filters=filters)

EC2 run instances with --iam-instance-profile strange error
I encounter strange behavior with `aws ec2 run-instances` which includes `--iam-instance-profile` flag.
With simple
```
aws ec2 run-instances --image-id ami-example1234567890
```

it works fine, instance is created. I get 200 response in log:
```
192.168.1.1 - - [11/Oct/2023 11:52:26] "POST / HTTP/1.1" 200 -
```

In case I include `--iam-instance-profile` flag like:
```
aws ec2 run-instances --image-id ami-example1234567890 --iam-instance-profile Name="arn:aws:iam::123456789012:instance-profile/admin-role"
```
or any `Name` content like:
```
aws ec2 run-instances --image-id ami-example1234567890 --iam-instance-profile Name="test"
```

I get error `An error occurred (NoSuchEntity) when calling the RunInstances operation: Instance profile arn:aws:iam::123456789012:instance-profile/admin-role not found`. 

With log:
```
192.168.65.1 - - [11/Oct/2023 11:52:39] "POST / HTTP/1.1" 404 -
```

But even with 404 error new instance is created.
I'm not against creating instance without validating such rare flag, but it fails to return correct 200 response.

I use docker image with version `4.2.5`.
All aws client commands I run against container like:
```
aws --endpoint-url=http://localhost:5000 ec2 run-instances
```

tests/test_ec2/test_instances.py::test_instance_iam_instance_profile
tests/test_ec2/test_instances.py::test_run_instance_with_block_device_mappings_missing_ebs tests/test_ec2/test_instances.py::test_get_instances_filtering_by_tag tests/test_ec2/test_instances.py::test_run_instance_and_associate_public_ip tests/test_ec2/test_instances.py::test_modify_instance_attribute_security_groups tests/test_ec2/test_instances.py::test_run_instance_cannot_have_subnet_and_networkinterface_parameter tests/test_ec2/test_instances.py::test_create_with_volume_tags tests/test_ec2/test_instances.py::test_get_instances_filtering_by_subnet_id tests/test_ec2/test_instances.py::test_run_instance_with_placement tests/test_ec2/test_instances.py::test_run_instance_with_additional_args[True] tests/test_ec2/test_instances.py::test_describe_instance_status_with_instances tests/test_ec2/test_instances.py::test_get_instances_filtering_by_dns_name tests/test_ec2/test_instances.py::test_run_multiple_instances_with_single_nic_template tests/test_ec2/test_instances.py::test_filter_wildcard_in_specified_tag_only tests/test_ec2/test_instances.py::test_get_instances_filtering_by_reason_code tests/test_ec2/test_instances.py::test_get_instances_filtering_by_account_id tests/test_ec2/test_instances.py::test_describe_instance_status_no_instances tests/test_ec2/test_instances.py::test_run_instance_with_block_device_mappings_using_no_device tests/test_ec2/test_instances.py::test_get_instance_by_security_group tests/test_ec2/test_instances.py::test_create_with_tags tests/test_ec2/test_instances.py::test_instance_terminate_discard_volumes tests/test_ec2/test_instances.py::test_instance_terminate_detach_volumes tests/test_ec2/test_instances.py::test_run_instance_in_subnet_with_nic_private_ip tests/test_ec2/test_instances.py::test_run_instance_with_nic_preexisting tests/test_ec2/test_instances.py::test_instance_detach_volume_wrong_path tests/test_ec2/test_instances.py::test_instance_attribute_source_dest_check tests/test_ec2/test_instances.py::test_run_instance_with_nic_autocreated tests/test_ec2/test_instances.py::test_run_instances_with_unknown_security_group tests/test_ec2/test_instances.py::test_run_instance_with_block_device_mappings_from_snapshot tests/test_ec2/test_instances.py::test_get_instances_filtering_by_instance_id tests/test_ec2/test_instances.py::test_get_instances_filtering_by_tag_name tests/test_ec2/test_instances.py::test_instance_attach_volume tests/test_ec2/test_instances.py::test_get_instances_filtering_by_ni_private_dns tests/test_ec2/test_instances.py::test_describe_instance_status_with_non_running_instances tests/test_ec2/test_instances.py::test_describe_instance_with_enhanced_monitoring tests/test_ec2/test_instances.py::test_create_instance_with_default_options tests/test_ec2/test_instances.py::test_warn_on_invalid_ami tests/test_ec2/test_instances.py::test_run_instance_with_security_group_name tests/test_ec2/test_instances.py::test_describe_instances_filter_vpcid_via_networkinterface tests/test_ec2/test_instances.py::test_get_paginated_instances tests/test_ec2/test_instances.py::test_run_instance_with_invalid_keypair tests/test_ec2/test_instances.py::test_get_instances_filtering_by_image_id tests/test_ec2/test_instances.py::test_describe_instances_with_keypair_filter tests/test_ec2/test_instances.py::test_describe_instances_pagination_error tests/test_ec2/test_instances.py::test_describe_instances_dryrun tests/test_ec2/test_instances.py::test_instance_reboot tests/test_ec2/test_instances.py::test_run_instance_with_invalid_instance_type tests/test_ec2/test_instances.py::test_run_instance_with_new_nic_and_security_groups tests/test_ec2/test_instances.py::test_run_instance_with_keypair tests/test_ec2/test_instances.py::test_instance_start_and_stop tests/test_ec2/test_instances.py::test_ec2_classic_has_public_ip_address tests/test_ec2/test_instances.py::test_describe_instance_status_with_instance_filter_deprecated tests/test_ec2/test_instances.py::test_describe_instance_attribute tests/test_ec2/test_instances.py::test_terminate_empty_instances tests/test_ec2/test_instances.py::test_instance_terminate_keep_volumes_implicit tests/test_ec2/test_instances.py::test_run_instance_with_block_device_mappings tests/test_ec2/test_instances.py::test_instance_termination_protection tests/test_ec2/test_instances.py::test_create_instance_from_launch_template__process_tags tests/test_ec2/test_instances.py::test_get_instances_filtering_by_source_dest_check tests/test_ec2/test_instances.py::test_get_instances_filtering_by_architecture tests/test_ec2/test_instances.py::test_describe_instance_without_enhanced_monitoring tests/test_ec2/test_instances.py::test_run_instance_mapped_public_ipv4 tests/test_ec2/test_instances.py::test_instance_terminate_keep_volumes_explicit tests/test_ec2/test_instances.py::test_get_instances_filtering_by_instance_type tests/test_ec2/test_instances.py::test_create_instance_ebs_optimized tests/test_ec2/test_instances.py::test_instance_launch_and_terminate tests/test_ec2/test_instances.py::test_instance_attribute_instance_type tests/test_ec2/test_instances.py::test_user_data_with_run_instance tests/test_ec2/test_instances.py::test_get_instances_filtering_by_private_dns tests/test_ec2/test_instances.py::test_get_instances_filtering_by_instance_group_id tests/test_ec2/test_instances.py::test_instance_with_nic_attach_detach tests/test_ec2/test_instances.py::test_get_instances_filtering_by_instance_group_name tests/test_ec2/test_instances.py::test_terminate_unknown_instances tests/test_ec2/test_instances.py::test_run_instance_with_availability_zone_not_from_region tests/test_ec2/test_instances.py::test_modify_delete_on_termination tests/test_ec2/test_instances.py::test_add_servers tests/test_ec2/test_instances.py::test_get_instances_filtering_by_vpc_id tests/test_ec2/test_instances.py::test_run_multiple_instances_in_same_command tests/test_ec2/test_instances.py::test_get_instances_filtering_by_state tests/test_ec2/test_instances.py::test_error_on_invalid_ami_format tests/test_ec2/test_instances.py::test_run_instance_with_additional_args[False] tests/test_ec2/test_instances.py::test_run_instance_with_default_placement tests/test_ec2/test_instances.py::test_run_instance_with_subnet tests/test_ec2/test_instances.py::test_instance_lifecycle tests/test_ec2/test_instances.py::test_run_instance_with_block_device_mappings_missing_size tests/test_ec2/test_instances.py::test_get_instances_by_id tests/test_ec2/test_instances.py::test_run_instance_with_security_group_id tests/test_ec2/test_instances.py::test_describe_instance_credit_specifications tests/test_ec2/test_instances.py::test_get_instances_filtering_by_tag_value tests/test_ec2/test_instances.py::test_error_on_invalid_ami tests/test_ec2/test_instances.py::test_describe_instance_status_with_instance_filter tests/test_ec2/test_instances.py::test_run_instance_in_subnet_with_nic_private_ip_and_public_association tests/test_ec2/test_instances.py::test_run_instance_with_specified_private_ipv4 tests/test_ec2/test_instances.py::test_instance_attribute_user_data