Pyjo.AWS.Credentials.AssumeRole - Credentials of a role of STS¶
from Pyjo.AWS.Credentials.AssumeRole import AssumeRole
from Pyjo.AWS.Credentials.Profile import Profile
provider = AssumeRole(source=Profile(), role_arn='arn:aws:iam::123456789012:role/admin')
credentials = provider.credentials()
# Or import the module, as in Google Python Style Guide
import Pyjo.AWS.Credentials.AssumeRole
import Pyjo.AWS.Credentials.Environment
provider = Pyjo.AWS.Credentials.AssumeRole.new(
source=Pyjo.AWS.Credentials.Environment.new(),
role_arn='arn:aws:iam::123456789012:role/deploy',
role_session_name='deploy',
external_id='4c1d0e4f',
duration_seconds=900,
region='eu-central-1',
)
provider.credentials_p().then(lambda credentials: print(credentials.expiration)).wait()
Pyjo.AWS.Credentials.AssumeRole is the provider of the credentials of
a role of AssumeRole of STS, signed with the credentials of another
provider, its source, as a profile of role_arn with source_profile or
credential_source has them, of Pyjo.AWS.Credentials.Profile. The
credentials of the source are kept by the source, so that they are got
again only when they expire.
See also¶
Pyjo.AWS.Credentials.Provider, Pyjo.AWS.Credentials.Profile,
Pyjo.AWS.Credentials.WebIdentity,
https://docs.aws.amazon.com/sdkref/latest/guide/feature-assume-role-credentials.html.
Classes¶
- class Pyjo.AWS.Credentials.AssumeRole.Pyjo_AWS_Credentials_AssumeRole(*, source: Pyjo_AWS_Credentials_Provider, role_arn: str, role_session_name: str | None = None, external_id: str | None = None, duration_seconds: int | None = None, region: str | None = None, config: Pyjo_AWS_Config | None = None, **kwargs: Any)[source]¶
Pyjo.AWS.Credentials.AssumeRoleinherits all attributes and methods fromPyjo.AWS.Credentials.Providerand implements the following new ones.- __init__(*, source: Pyjo_AWS_Credentials_Provider, role_arn: str, role_session_name: str | None = None, external_id: 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.AssumeRole.new(source=source, role_arn='arn:aws:iam::123456789012:role/admin')
Construct a new
Pyjo.AWS.Credentials.AssumeRoleobject, with the options ofPyjo.AWS.Credentials.Provider.
- config¶
config = provider.config
The shared files of the endpoint 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.
- external_id¶
external_id = provider.external_id
The external ID that the trust policy of the role requires, or
None.
- async fetch() Pyjo_AWS_Credentials | None[source]¶
credentials = await provider.fetch()
The credentials of the role, of the credentials of
source.
- role_arn¶
arn = provider.role_arn
The ARN of the role.
- role_session_name¶
name = provider.role_session_name
The name of the session of the role, which CloudTrail logs, or
Noneforpyjo-aws-and the time, as botocore names it.
- source¶
source = provider.source
The provider of the credentials that sign
AssumeRole.
- Pyjo.AWS.Credentials.AssumeRole.VERSION = '2011-06-15'¶
The version of the API of STS.
- Pyjo.AWS.Credentials.AssumeRole.credentials_of(dom: Pyjo_DOM, provider: str) Pyjo_AWS_Credentials[source]¶
credentials = Pyjo.AWS.Credentials.AssumeRole.credentials_of(dom, 'assume-role')
The credentials of the XML of a response of STS, of its elements
Credentials, and the account of the ARN ofAssumedRoleUser.
- Pyjo.AWS.Credentials.AssumeRole.sts_client(ua: Pyjo_UserAgent, config: Pyjo_AWS_Config, region: str | None = None, unsigned: bool = False) Pyjo_AWS_Client[source]¶
sts = Pyjo.AWS.Credentials.AssumeRole.sts_client(ua, config)
A new client of STS of a provider, with its user agent, in a region, the one of the shared files, or
us-east-1, whose regional endpoint is the global one.