airflow.providers.amazon.aws.hooks.base_aws

This module contains Base AWS Hook.

See also

For more information on how to use this hook, take a look at the guide: Amazon Web Services Connection

Module Contents

Classes

BaseSessionFactory

Base AWS Session Factory class to handle boto3 session creation.

AwsGenericHook

Generic class for interact with AWS.

AwsBaseHook

Base class for interact with AWS.

Functions

resolve_session_factory()

Resolves custom SessionFactory class

Attributes

BaseAwsConnection

SessionFactory

airflow.providers.amazon.aws.hooks.base_aws.BaseAwsConnection[source]
class airflow.providers.amazon.aws.hooks.base_aws.BaseSessionFactory(conn, region_name=None, config=None)[source]

Bases: airflow.utils.log.logging_mixin.LoggingMixin

Base AWS Session Factory class to handle boto3 session creation. It can handle most of the AWS supported authentication methods.

User can also derive from this class to have full control of boto3 session creation or to support custom federation.

See also

property extra_config: dict[str, Any][source]

AWS Connection extra_config.

property region_name: str | None[source]

AWS Region Name read-only property.

property config: Config | None[source]

Configuration for botocore client read-only property.

property role_arn: str | None[source]

Assume Role ARN from AWS Connection

conn()[source]

Cached AWS Connection Wrapper.

basic_session()[source]

Cached property with basic boto3.session.Session.

create_session()[source]

Create boto3 Session from connection config.

class airflow.providers.amazon.aws.hooks.base_aws.AwsGenericHook(aws_conn_id=default_conn_name, verify=None, region_name=None, client_type=None, resource_type=None, config=None)[source]

Bases: airflow.hooks.base.BaseHook, Generic[BaseAwsConnection]

Generic class for interact with AWS. This class provide a thin wrapper around the boto3 python library.

Parameters
property service_config: dict[source]
property region_name: str | None[source]

AWS Region Name read-only property.

property config: botocore.config.Config[source]

Configuration for botocore client read-only property.

property verify: bool | str | None[source]

Verify or not SSL certificates boto3 client/resource read-only property.

property conn_region_name: str[source]

Get actual AWS Region Name from Hook connection (cached).

property conn_partition: str[source]

Get associated AWS Region Partition from Hook connection (cached).

conn_name_attr = 'aws_conn_id'[source]
default_conn_name = 'aws_default'[source]
conn_type = 'aws'[source]
hook_name = 'Amazon Web Services'[source]
conn_config()[source]

Get the Airflow Connection object and wrap it in helper (cached).

get_session(region_name=None)[source]

Get the underlying boto3.session.Session(region_name=region_name).

get_client_type(region_name=None, config=None)[source]

Get the underlying boto3 client using boto3 session

get_resource_type(region_name=None, config=None)[source]

Get the underlying boto3 resource using boto3 session

conn()[source]

Get the underlying boto3 client/resource (cached)

Returns

boto3.client or boto3.resource

Return type

BaseAwsConnection

conn_client_meta()[source]

Get botocore client metadata from Hook connection (cached).

get_conn()[source]

Get the underlying boto3 client/resource (cached)

Implemented so that caching works as intended. It exists for compatibility with subclasses that rely on a super().get_conn() method.

Returns

boto3.client or boto3.resource

Return type

BaseAwsConnection

get_credentials(region_name=None)[source]

Get the underlying botocore.Credentials object.

This contains the following authentication attributes: access_key, secret_key and token. By use this method also secret_key and token will mask in tasks logs.

expand_role(role, region_name=None)[source]

If the IAM role is a role name, get the Amazon Resource Name (ARN) for the role. If IAM role is already an IAM role ARN, no change is made.

Parameters
  • role (str) – IAM role name or ARN

  • region_name (str | None) – Optional region name to get credentials for

Returns

IAM role ARN

Return type

str

static retry(should_retry)[source]

A decorator that provides a mechanism to repeat requests in response to exceeding a temporary quote limit.

static get_ui_field_behaviour()[source]

Returns custom UI field behaviour for AWS Connection.

test_connection()[source]

Tests the AWS connection by call AWS STS (Security Token Service) GetCallerIdentity API.

waiter_path()[source]
get_waiter(waiter_name)[source]

First checks if there is a custom waiter with the provided waiter_name and uses that if it exists, otherwise it will check the service client for a waiter that matches the name and pass that through.

Parameters

waiter_name (str) – The name of the waiter. The name should exactly match the name of the key in the waiter model file (typically this is CamelCase).

list_waiters()[source]

Returns a list containing the names of all waiters for the service, official and custom.

class airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook(aws_conn_id=default_conn_name, verify=None, region_name=None, client_type=None, resource_type=None, config=None)[source]

Bases: AwsGenericHook[Union[boto3.client, boto3.resource]]

Base class for interact with AWS. This class provide a thin wrapper around the boto3 python library.

Parameters
airflow.providers.amazon.aws.hooks.base_aws.resolve_session_factory()[source]

Resolves custom SessionFactory class

airflow.providers.amazon.aws.hooks.base_aws.SessionFactory[source]

Was this entry helpful?