class_docstr: Poll the state of the AWS EC2 instance until the instance reaches the target state.
  
  .. seealso::
      For more information on how to use this sensor, take a look at the guide:
      :ref:`howto/sensor:EC2InstanceStateSensor`
  
  :param target_state: target state of instance
  :param instance_id: id of the AWS EC2 instance
  :param region_name: (optional) aws region name associated with the client
  :param deferrable: if True, the sensor will run in deferrable mode
code: def execute_complete(self, context, event=None):
      if event["status"] != "success":
          # TODO: remove this if check when min_airflow_version is set to higher than 2.7.1
          message = f"Error: {event}"
          if self.soft_fail:
              raise AirflowSkipException(message)
          raise AirflowException(message)
      return
  
file_path: airflow/airflow/providers/amazon/aws/sensors/ec2.py
imports: from __future__ import annotations
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Sequence
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, AirflowSkipException
  from airflow.providers.amazon.aws.hooks.ec2 import EC2Hook
  from airflow.providers.amazon.aws.triggers.ec2 import EC2StateSensorTrigger
  from airflow.sensors.base import BaseSensorOperator
label_desc: Use image node_id 5 for calling the EC2InstanceStateSensor obj's underlying member method code with example usage: obj.execute_complete(context, event) without return types