Pyjo.AWS.Credentials.Profile - Credentials of a profile of the shared files
from Pyjo.AWS.Credentials.Profile import Profile
credentials = Profile().credentials()
# Or import the module, as in Google Python Style Guide
import Pyjo.AWS.Config
import Pyjo.AWS.Credentials.Profile
provider = Pyjo.AWS.Credentials.Profile.new(config=Pyjo.AWS.Config.new(profile='dev'))
print(provider.credentials().access_key_id)
Pyjo.AWS.Credentials.Profile is the provider of the credentials of a
profile of the shared files of Pyjo.AWS.Config, as the SDKs of AWS
take them: the keys aws_access_key_id, aws_secret_access_key and
aws_session_token of the profile, or the session of aws login of its
login_session, of Pyjo.AWS.Credentials.Login, or the program of its
credential_process, of Pyjo.AWS.Credentials.Process, or the role
of IAM Identity Center of its sso_session or sso_start_url, of
Pyjo.AWS.Credentials.SSO, which comes before them, or its
role_arn, which comes first:
[profile admin]
role_arn = arn:aws:iam::123456789012:role/admin
source_profile = dev
role_session_name = alice
external_id = 4c1d0e4f
duration_seconds = 900
The role of source_profile is assumed with the credentials of that
profile, of Pyjo.AWS.Credentials.AssumeRole, which may be a role
itself, whose cycle is an error; a source profile with its own keys gives
those, without its role, as botocore does, so that a profile may be the
source of its own role. The role of credential_source is assumed with
the credentials of Environment, of Pyjo.AWS.Credentials.Environment,
EcsContainer, of Pyjo.AWS.Credentials.Container, or
Ec2InstanceMetadata, of Pyjo.AWS.Credentials.InstanceMetadata, and the role of
web_identity_token_file with the token of the file, of
Pyjo.AWS.Credentials.WebIdentity. A role with mfa_serial is an
error, as there is no prompt for the code.
A profile that is not in the files is an error, but the profile default,
which a machine without the files has not either.
-
class Pyjo.AWS.Credentials.Profile.Pyjo_AWS_Credentials_Profile(*, config: Pyjo_AWS_Config | None = None, profile: str | None = None, roles: bool = True, visited: Collection[str] = (), **kwargs: Any)[source]
Pyjo.AWS.Credentials.Profile inherits all attributes and methods
from Pyjo.AWS.Credentials.Provider and implements the following
new ones.
-
__init__(*, config: Pyjo_AWS_Config | None = None, profile: str | None = None, roles: bool = True, visited: Collection[str] = (), **kwargs: Any) → None[source]
provider = Pyjo.AWS.Credentials.Profile.new()
provider = Pyjo.AWS.Credentials.Profile.new(config=Pyjo.AWS.Config.new(profile='dev'))
provider = Pyjo.AWS.Credentials.Profile.new(profile='dev', roles=False)
Construct a new Pyjo.AWS.Credentials.Profile object, with the
options of Pyjo.AWS.Credentials.Provider.
-
config
config = provider.config
provider.config = Pyjo.AWS.Config.new(profile='dev')
The shared files, a new Pyjo.AWS.Config object by default.
-
async fetch() → Pyjo_AWS_Credentials | None[source]
credentials = await provider.fetch()
The credentials of the profile, or None of a profile without them.
-
profile
-
The name of the profile, the
profile of config
by default.
-
roles
-
Assume the role of role_arn, true by default, and false for a
source profile with keys of its own.
-
visited
-
The profiles whose roles have this one as their source, of which a
source profile is a cycle.