Core concepts of Boto3
- There are few concepts of boto3 (aws sdk) like Session, Resource, Client, Meta, Collections, Paginators
- In this post we will discuss about the kehy difference between Resource, Client and Session
Session
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
|
|
Custom session
You can also manage your own session and create low-level clients or resource clients from it:
|
|
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 (string) – AWS access key ID
- aws_secret_access_key (string) – AWS secret access key
- aws_session_token (string) – AWS temporary session token
- region_name (string) – Default region when creating new connections
- botocore_session (botocore.session.Session) – Use this Botocore session instead of creating a new default one.
- profile_name (string) – The name of a profile to use. If not given, then the default profile is used.
Resource
Resources represent an object-oriented interface to Amazon Web Services (AWS). They provide a higher-level abstraction than the raw, low-level calls made by service clients. To use resources, you invoke the resource() method of a Session and pass in a service name
|
|
Clients
Clients provide a low-level interface to AWS whose methods map close to 1:1 with service APIs. All service operations are supported by clients. Clients are generated from a JSON service definition file.
Diffeence between client and resource
|
|