code: def create_key_pair(key_name: str):
      client = boto3.client("ec2")
  
      key_pair_id = client.create_key_pair(KeyName=key_name)["KeyName"]
      # Creating the key takes a very short but measurable time, preventing race condition:
      client.get_waiter("key_pair_exists").wait(KeyNames=[key_pair_id])
  
      return key_pair_id
  
file_path: airflow/tests/system/providers/amazon/aws/example_ec2.py
imports: from __future__ import annotations
  from datetime import datetime
  from operator import itemgetter
  import boto3
  from airflow.decorators import task
  from airflow.models.baseoperator import chain
  from airflow.models.dag import DAG
  from airflow.providers.amazon.aws.operators.ec2 import EC2CreateInstanceOperator, EC2HibernateInstanceOperator, EC2RebootInstanceOperator, EC2StartInstanceOperator, EC2StopInstanceOperator, EC2TerminateInstanceOperator
  from airflow.providers.amazon.aws.sensors.ec2 import EC2InstanceStateSensor
  from airflow.utils.trigger_rule import TriggerRule
  from tests.system.providers.amazon.aws.utils import ENV_ID_KEY, SystemTestContextBuilder
  from tests.system.utils import get_test_run
label_desc: Use image node_id 2 for calling a global function with example usage: create_key_pair(key_name) and returns: key_pair_id