airflow.providers.amazon.aws.hooks.ec2

Module Contents

class airflow.providers.amazon.aws.hooks.ec2.EC2Hook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with AWS EC2 Service.

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

See also

AwsBaseHook

get_instance(self, instance_id: str)[source]

Get EC2 instance by id and return it.

Parameters

instance_id (str) -- id of the AWS EC2 instance

Returns

Instance object

Return type

ec2.Instance

get_instance_state(self, instance_id: str)[source]

Get EC2 instance state by id and return it.

Parameters

instance_id (str) -- id of the AWS EC2 instance

Returns

current state of the instance

Return type

str

wait_for_state(self, instance_id: str, target_state: str, check_interval: float)[source]

Wait EC2 instance until its state is equal to the target_state.

Parameters
  • instance_id (str) -- id of the AWS EC2 instance

  • target_state (str) -- target state of instance

  • check_interval (float) -- time in seconds that the job should wait in between each instance state checks until operation is completed

Returns

None

Return type

None

Was this entry helpful?