Skip to content

Commit

Permalink
Merge pull request #203 from AdaCore/pr/move_awscredentials_to_e3_aws
Browse files Browse the repository at this point in the history
Move AWSCredentials type from e3-auth to e3-aws
  • Loading branch information
liaiss committed Mar 30, 2023
2 parents 3d1ee29 + 9100413 commit 02753eb
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/e3/aws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,28 @@
logger = logging.getLogger(__name__)

if TYPE_CHECKING:
from typing import Any, Callable
from typing import Any, TypedDict, Callable
import botocore.client
import botocore.stub

class AWSCredentials(TypedDict, total=False):
"""Annotate a dict containing AWS credentials.
:cvar Version: credentials format version
:cvar AccessKeyId: access key ID that identifies the temporary security
credentials
:cvar SecretAccessKey: secret access key that can be used to sign requests
:cvar SessionToken: token that users must pass to the service API to use
the temporary credentials
:cvar Expiration: date on which the current credentials expire
"""

Version: int
AccessKeyId: str
SecretAccessKey: str
SessionToken: str
Expiration: str


class AWSSessionRunError(E3Error):
def __init__(self, message: str, origin: str, process: Run | None = None) -> None:
Expand All @@ -51,7 +69,7 @@ def __init__(
regions: list[str] | None = None,
stub: bool = False,
profile: str | None = None,
credentials: dict | None = None,
credentials: AWSCredentials | None = None,
) -> None:
"""Initialize an AWS session.
Expand Down Expand Up @@ -128,7 +146,7 @@ def assume_role_get_credentials(
role_session_name: str,
session_duration: int | None = None,
as_env_var: bool = False,
) -> dict[str, Any]:
) -> AWSCredentials:
"""Return credentials for ``role_arn``.
:param role_arn: ARN of the role to assume
Expand Down

0 comments on commit 02753eb

Please sign in to comment.