Session reference - Boto3 1.38.12 documentation (original) (raw)

Toggle table of contents sidebar

class boto3.session.Session(aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, region_name=None, botocore_session=None, profile_name=None, aws_account_id=None)[source]

A session stores configuration state and allows you to create service clients and resources.

Parameters:

property available_profiles

The profiles available to the session credentials

client(service_name, region_name=None, api_version=None, use_ssl=True, verify=None, endpoint_url=None, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, config=None, aws_account_id=None)[source]

Create a low-level service client by name.

Parameters:

Returns:

Service client instance

property events

The event emitter for a session

get_available_partitions()[source]

Lists the available partitions

Return type:

list

Returns:

Returns a list of partition names (e.g., [“aws”, “aws-cn”])

get_available_regions(service_name, partition_name='aws', allow_non_regional=False)[source]

Lists the region and endpoint names of a particular partition.

The list of regions returned by this method are regions that are explicitly known by the client to exist and is not comprehensive. A region not returned in this list may still be available for the provided service.

Parameters:

Returns:

Returns a list of endpoint names (e.g., [“us-east-1”]).

get_available_resources()[source]

Get a list of available services that can be loaded as resource clients via Session.resource().

Return type:

list

Returns:

List of service names

get_available_services()[source]

Get a list of available services that can be loaded as low-level clients via Session.client().

Return type:

list

Returns:

List of service names

get_credentials()[source]

Return the botocore.credentials.Credentials object associated with this session. If the credentials have not yet been loaded, this will attempt to load them. If they have already been loaded, this will return the cached credentials.

get_partition_for_region(region_name)[source]

Lists the partition name of a particular region.

Parameters:

region_name (string) – Name of the region to list partition for (e.g., us-east-1).

Return type:

string

Returns:

Returns the respective partition name (e.g., aws).

property profile_name

The read-only profile name.

property region_name

The read-only region name.

resource(service_name, region_name=None, api_version=None, use_ssl=True, verify=None, endpoint_url=None, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, config=None)[source]

Create a resource service client by name.

Parameters:

Returns:

Subclass of ServiceResource