Pyjo.AWS.Credentials.WebIdentity - Credentials of a role of a web identity¶
from Pyjo.AWS.Credentials.WebIdentity import WebIdentity
credentials = WebIdentity().credentials()
# Or import the module, as in Google Python Style Guide
import Pyjo.AWS.Credentials.WebIdentity
provider = Pyjo.AWS.Credentials.WebIdentity.new(
role_arn='arn:aws:iam::123456789012:role/ci', token_file='/var/run/secrets/token', role_session_name='ci'
)
provider.credentials_p().then(lambda credentials: print(credentials.expiration)).wait()
Pyjo.AWS.Credentials.WebIdentity is the provider of the credentials
of a role of AssumeRoleWithWebIdentity of STS, with the token of OpenID
Connect of a file, as the service accounts of EKS and the OIDC of CI have it:
of the AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_ARN and
AWS_ROLE_SESSION_NAME environment variables by default, or of
web_identity_token_file and role_arn of a profile, of
Pyjo.AWS.Credentials.Profile. The request is not signed, as the token
is its proof, and the file is read each time, as the token is rotated.
A token file without a role, or a role without a token file, of the environment, is an error.
See also¶
Pyjo.AWS.Credentials.Provider, Pyjo.AWS.Credentials.AssumeRole,
https://docs.aws.amazon.com/sdkref/latest/guide/feature-assume-role-credentials.html.
Classes¶
- class Pyjo.AWS.Credentials.WebIdentity.Pyjo_AWS_Credentials_WebIdentity(*, role_arn: str | None = None, token_file: str | None = None, role_session_name: str | None = None, duration_seconds: int | None = None, region: str | None = None, config: Pyjo_AWS_Config | None = None, **kwargs: Any)[source]¶
Pyjo.AWS.Credentials.WebIdentityinherits all attributes and methods fromPyjo.AWS.Credentials.Providerand implements the following new ones.- __init__(*, role_arn: str | None = None, token_file: str | None = None, role_session_name: str | None = None, duration_seconds: int | None = None, region: str | None = None, config: Pyjo_AWS_Config | None = None, **kwargs: Any) None[source]¶
provider = Pyjo.AWS.Credentials.WebIdentity.new() provider = Pyjo.AWS.Credentials.WebIdentity.new(role_arn=arn, token_file='/var/run/secrets/token')
Construct a new
Pyjo.AWS.Credentials.WebIdentityobject, with the options ofPyjo.AWS.Credentials.Provider, and the role, the token file and the name of the session of the environment withoutrole_arnandtoken_file.
- config¶
config = provider.config
The shared files of the endpoint and the region of STS, a new
Pyjo.AWS.Configobject by default.
- duration_seconds¶
seconds = provider.duration_seconds
The duration of the credentials, or
Nonefor the default of STS, one hour.
- async fetch() Pyjo_AWS_Credentials | None[source]¶
credentials = await provider.fetch()
The credentials of the role, of the token of the file, or
Nonewithout a role and a token file.
- role_arn¶
arn = provider.role_arn
The ARN of the role, of the
AWS_ROLE_ARNenvironment variable by default.
- role_session_name¶
name = provider.role_session_name
The name of the session of the role, of the
AWS_ROLE_SESSION_NAMEenvironment variable by default, orNoneforpyjo-aws-and the time.
- token_file¶
path = provider.token_file
The file of the token, of the
AWS_WEB_IDENTITY_TOKEN_FILEenvironment variable by default.