Pyjo.AWS.Credentials.Container - Credentials of a container of ECS or EKS¶
from Pyjo.AWS.Credentials.Container import Container
credentials = Container().credentials()
# Or import the module, as in Google Python Style Guide
import Pyjo.AWS.Credentials.Container
provider = Pyjo.AWS.Credentials.Container.new(full_uri='http://127.0.0.1:8080/credentials', token='secret')
provider.credentials_p().then(lambda credentials: print(credentials.expiration)).wait()
Pyjo.AWS.Credentials.Container is the provider of the credentials of
the role of a task of ECS, of a pod of EKS Pod Identity, or of a server of
credentials on the loopback, as the agent of the container serves them: of
the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable, a path on
http://169.254.170.2, which ECS sets, or of
AWS_CONTAINER_CREDENTIALS_FULL_URI, a URL, which EKS Pod Identity sets,
with the token of AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, read each time,
as EKS rotates it, or of AWS_CONTAINER_AUTHORIZATION_TOKEN in the header
Authorization.
A URL of HTTP is one of the agents of ECS and EKS, 169.254.170.2,
169.254.170.23 or fd00:ec2::23, or of the loopback, as the SDKs of AWS
allow it, and a URL of HTTPS is any. The user agent of the provider has a
timeout of 2 seconds and keeps no connections, and a request is tried 3
times, as botocore does.
See also¶
Pyjo.AWS.Credentials.Provider, Pyjo.AWS.Credentials.Chain,
https://docs.aws.amazon.com/sdkref/latest/guide/feature-container-credentials.html.
Classes¶
- Pyjo.AWS.Credentials.Container.HOST = 'http://169.254.170.2'¶
The agent of ECS, of a relative URI.
- class Pyjo.AWS.Credentials.Container.Pyjo_AWS_Credentials_Container(*, relative_uri: str | None = None, full_uri: str | None = None, token: str | None = None, token_file: str | None = None, timeout: float = 2, attempts: int = 3, ua: Pyjo_UserAgent | None = None, **kwargs: Any)[source]¶
Pyjo.AWS.Credentials.Containerinherits all attributes and methods fromPyjo.AWS.Credentials.Providerand implements the following new ones.- __init__(*, relative_uri: str | None = None, full_uri: str | None = None, token: str | None = None, token_file: str | None = None, timeout: float = 2, attempts: int = 3, ua: Pyjo_UserAgent | None = None, **kwargs: Any) None[source]¶
provider = Pyjo.AWS.Credentials.Container.new() provider = Pyjo.AWS.Credentials.Container.new(relative_uri='/v2/credentials/1234') provider = Pyjo.AWS.Credentials.Container.new(full_uri='http://169.254.170.23/v1/credentials', token_file='/var/run/secrets/token')
Construct a new
Pyjo.AWS.Credentials.Containerobject, with the options ofPyjo.AWS.Credentials.Provider, and the URI and the token of the environment withoutrelative_uriandfull_uri.
- attempts¶
attempts = provider.attempts
The number of the attempts of a request that fails, 3 by default.
- authorization() str | None[source]¶
token = provider.authorization()
The value of the header
Authorization, oftoken_fileortoken, orNone, without the white space around it, which has no line breaks.
- async fetch() Pyjo_AWS_Credentials | None[source]¶
credentials = await provider.fetch()
The credentials of the container, or
Nonewithout a URI.
- full_uri¶
url = provider.full_uri
The URL of the credentials, of the
AWS_CONTAINER_CREDENTIALS_FULL_URIenvironment variable by default.
- relative_uri¶
path = provider.relative_uri
The path of the credentials on
HOST, of theAWS_CONTAINER_CREDENTIALS_RELATIVE_URIenvironment variable by default, which comes overfull_uri.
- token¶
token = provider.token
The token of the header
Authorization, of theAWS_CONTAINER_AUTHORIZATION_TOKENenvironment variable by default.
- token_file¶
path = provider.token_file
The file of the token, which comes over
token, of theAWS_CONTAINER_AUTHORIZATION_TOKEN_FILEenvironment variable by default.
- url() str | None[source]¶
url = provider.url()
The URL of the credentials, of
relative_urionHOST, or offull_uri, which is HTTPS or of an agent or the loopback, orNone.