aws_utils
Utility functions for interacting with AWS services.
Module
Functions
check_aws_credentials_are_valid
def check_aws_credentials_are_valid( boto3_session: Optional[boto3.Session] = None,) ‑> None:
Checks if the provided AWS credentials are valid.
Arguments
boto3_session
: A Boto3 session with the provided AWS credentials. If None, a new session will be created using the default AWS credentials.
Raises
AWSError
: If the provided AWS credentials are invalid.
get_boto_session
def get_boto_session(aws_profile: Optional[str] = 'default') ‑> boto3.session.Session:
Creates a Boto3 session using provided AWS credentials.
If AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION (and optionally AWS_SESSION_TOKEN) environment variables are set, these are used as priority.
Otherwise, if aws_profile is provided, credentials will be loaded from the AWS credentials file and the provided profile is used. The default path to the AWS credentials can be overridden using the AWS_SHARED_CREDENTIALS_FILE environment variable.
Arguments
aws_profile
: The AWS profile to use for credentials if credentials are to be loaded from the credentials file. Defaults to "default".
Returns A Boto3 session with the provided AWS credentials.
Raises
AWSError
: If there is not enough information to construct a boto3 Session.
Classes
AWSError
class AWSError(*args, **kwargs):
Exception related to AWS errors.
Ancestors
- BitfountError
- builtins.Exception
- builtins.BaseException