Session Boto3 Docs 1.17.85 documentation

A session manages state about a particular configuration. By default, a session is created for you when needed. However, it's possible and recommended that in some scenarios you maintain your own session. Sessions typically store the following:

Overview

A session manages state about a particular configuration. By default, a session is created for you when needed. However, it's possible and recommended that in some scenarios you maintain your own session. Sessions typically store the following:

  • Credentials
  • AWS Region
  • Other configurations related to your profile

Default session

Boto3 acts as a proxy to the default session. This is created automatically when you create a low-level client or resource client:

import boto3 # Using the default session sqs = boto3.client('sqs') s3 = boto3.resource('s3') 

Session configurations

You can configure each session with specific credentials, AWS Region information, or profiles. The most common configurations you might use are:

  • aws_access_key_id - A specific AWS access key ID.
  • aws_secret_access_key - A specific AWS secret access key.
  • region_name - The AWS Region where you want to create new connections.
  • profile_name - The profile to use when creating your session.

Note

Only set the profile_name parameter when a specific profile is required for your session. To use the default profile, don’t set the profile_name parameter at all. If the profile_name parameter isn't set and there is no default profile, an empty config dictionary will be used.

For a detailed list of per-session configurations, see the Session core reference.

ncG1vNJzZmian6m8dHrAppizp56WxLR6wqikaK5hZLGwr9SmnKeskam2sLqOmqeiZ2Fjfnh6l25moK2ZmbJwv8SsqqKnnmO1tbnL

 Share!