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 __init__(
      self,
      *,
      target_state: str,
      instance_id: str,
      aws_conn_id: str = "aws_default",
      region_name: str | None = None,
      deferrable: bool = conf.getboolean(
          "operators", "default_deferrable", fallback=False
      ),
      **kwargs,
  ):
      if target_state not in self.valid_states:
          raise ValueError(f"Invalid target_state: {target_state}")
      super().__init__(**kwargs)
      self.target_state = target_state
      self.instance_id = instance_id
      self.aws_conn_id = aws_conn_id
      self.region_name = region_name
      self.deferrable = deferrable
  
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 1 to create a new EC2InstanceStateSensor object from inherited base classes: BaseSensorOperator with example: obj = EC2InstanceStateSensor()