Amazon Web Services Collection
This collection runs on top of Boto3.
Early development. Raise an issue if you encounter any bugs.
Source code • Requirements • Installation • Authentication • Deployment
Requirements
- Python 3.x
- Boto3
- AWS configuration files
~/.aws/credentials
and~/.aws/config
- This is optional but highly recommended for falling back to Boto3 authentication flow
Installation
Virtual environment (pip)
python3 -m venv venv
source venv/bin/activate
pip install avtomat-aws
aaws --help
Global (recommended: pipx)
pipx install avtomat-aws
aaws --help
Once installed you can use actions directly through the command line or import them in your code.
Review the list of actions available and their minimum IAM permissions required.
Examples are a great place to explore programmatic usage and chaining ideas.
Authentication
This collection supports the following authentication methods, in order:
- Profile
- Credentials
- Assume role
- Fallback to Boto3 authentication flow
Quick start
- CLI:
aaws sts whoami
- Programmatic:
from avtomat_aws import sts response = sts.whoami() print(response)
Examples
CLI
- Authenticate profile
- Linux
eval $(aaws sts create_session --profile <NAME>) aaws sts whoami
- Windows
aaws sts create_session --profile <NAME> | Invoke-Expression aaws sts whoami
- Linux
- Authenticate credentials
- Linux
eval $(aaws sts create_session --access_key <KEY> --secret_key <KEY>) aaws sts whoami
- Windows
aaws sts create_session --access_key <KEY> --secret_key <KEY> | Invoke-Expression aaws sts whoami
- Linux
- Assume role with MFA
- Linux
eval $(aaws sts create_session --role_arn <ARN> --mfa_serial <ARN> --mfa_token <CODE>) aaws sts whoami
- Windows
aaws sts create_session --role_arn <ARN> --mfa_serial <ARN> --mfa_token <CODE> | Invoke-Expression aaws sts whoami
- Linux
- Assume role without MFA
- Linux
eval $(aaws sts create_session --role_arn <ARN>) aaws sts whoami
- Windows
aaws sts create_session --role_arn <ARN> | Invoke-Expression aaws sts whoami
- Linux
- Fallback to Boto3 authentication flow
aaws sts whoami
Programmatic
- Authenticate credentials
from avtomat_aws import sts session = sts.create_session(access_key="KEY", secret_key="KEY") response = sts.whoami(session) print(response)
- Assume role
from avtomat_aws import sts session = sts.create_session(role_arn="ARN_HERE") response = sts.whoami(session) print(response)
- Fallback to Boto3 authentication flow
from avtomat_aws import sts response = sts.whoami() print(response)
For more details, refer to Create Session.
Deployment
AWS Lambda
This collection can be used by AWS Lambda functions with python3.x
runtime.
Refer to Deploy for deployment instructions.