# AWS CLI v2 for Python
[![PyPI - awscliv2](https://img.shields.io/pypi/v/awscliv2.svg?color=blue&label=awscliv2)](https://pypi.org/project/awscliv2)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/awscliv2.svg?color=blue)](https://pypi.org/project/awscliv2)
[![PyPI - Downloads](https://static.pepy.tech/badge/awscliv2)](https://pepy.tech/project/awscliv2)
Wrapper for [AWS CLI v2](https://awscli.amazonaws.com/v2/documentation/api/latest/index.html).
- [AWS CLI v2 for Python](#aws-cli-v2-for-python)
- [Features](#features)
- [Before you start](#before-you-start)
- [Installation](#installation)
- [Usage](#usage)
- [From command line](#from-command-line)
- [Docker fallback](#docker-fallback)
- [Extra commands](#extra-commands)
- [As a Python module](#as-a-python-module)
- [Development](#development)
- [How to help](#how-to-help)
- [Versioning](#versioning)
- [Latest changes](#latest-changes)
## Features
- No dependency hell, like with original [awscli](https://pypi.org/project/awscli/)
- Can install and update `awscliv2` binaries
- Provides access to all AWS services
- Has Python interface `awscliv2.api.AWSAPI`
## Before you start
- This is not an official AWS CLI v2 application, [rant there](https://github.com/aws/aws-cli/issues/4947)
- Check the source code of this app, as you are working with sensitive data
- By default this app uses [amazon/aws-cli](https://hub.docker.com/r/amazon/aws-cli) Docker image
- To use [binaries for your OS](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html), run `awsv2 --install`
- Cross-check the source code again, probably I want to
[steal your credentials](https://blog.sonatype.com/python-packages-upload-your-aws-keys-env-vars-secrets-to-web)!
## Installation
```bash
python -m pip install awscliv2
```
You can add an alias to your `~/.bashrc` or `~/.zshrc` to use it as a regular `AWS CLI v2`
```bash
alias aws='awsv2'
```
## Usage
### From command line
Install `AWS CLI v2`:
```bash
# do not worry if this fails, you can still use awsv2 if you have docker installed
awsv2 --install
```
Configure default profile if needed:
```bash
AWS_ACCESS_KEY_ID='my-access-key'
AWS_SECRET_ACCESS_KEY='my-secret-key'
# --configure <profile_name> <aws_access_key_id> <aws_secret_access_key> [<aws_session_token>]
awsv2 --configure default ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}
awsv2 configure set region us-west-1
```
Use `AWS CLI` as usual:
```bash
# alias for
# docker run --rm -i -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli $@
awsv2 s3 ls
# or as a python module
python -m awscliv2 s3 ls
```
Also, you can check [scripts/example.sh](https://github.com/youtype/awscliv2/blob/main/scripts/example.sh)
### Docker fallback
Unless you run `awsv2 --install` once, application will use [amazon/aws-cli](https://hub.docker.com/r/amazon/aws-cli) Docker image. The image is not ideal, and it uses `root` user, so fix downloaded file permissions manually. Or just run `awsv2 --install`
Update it with `docker pull amazon/aws-cli`.
Container uses two volumes:
- `$HOME/.aws` -> `/root/.aws` - credentials and config store
- `$(cwd)` -> `/aws` - Docker image workdir
### Extra commands
`awscliv2` contains a few commands to make your life easier, especially in CI or any non-TTY environment.
- `awsv2 -U/--update/--install` - Install `AWS CLI v2`
- `awsv2 --configure <profile_name> <aws_access_key_id> <aws_secret_access_key> [<aws_session_token>] [<region>]` - set profile in `~/.aws/credentials`
- `awsv2 --assume-role <profile_name> <source_profile> <role_arn>` - create a new profile with assume role credentials
- `awsv2 -V/--version` - Output `awscliv2` and `AWS CLI v2` versions
### As a Python module
Basic usage
```python
from awscliv2.api import AWSAPI
from awscliv2.exceptions import AWSCLIError
aws_api = AWSAPI()
try:
output = aws_api.execute(["s3", "ls"])
except AWSCLIError as e:
print(f"Something went wrong: {e}")
else:
print(output)
```
Install binaries for your OS from Python
```python
from awscliv2.installers import install_multiplatform
install_multiplatform()
```
You can also set credentials or assume roles
```python
from awscliv2.api import AWSAPI
aws_api = AWSAPI()
aws_api.set_credentials(
profile_name="my_profile",
aws_access_key_id="access_key",
aws_secret_access_key="secret_key",
region="us-east-1",
)
aws_api.assume_role(
profile_name="my_profile",
source_profile="source_profile",
role_arn="role_arn",
)
```
## Development
- Install [poetry](https://python-poetry.org/)
- Run `poetry install`
- Use `black` formatter in your IDE
## How to help
- Ping AWS team to release an official PyPI package
- Share your experience in issues
## Versioning
`awscliv2` version follows [PEP 440](https://www.python.org/dev/peps/pep-0440/).
## Latest changes
Full changelog can be found in [Releases](https://github.com/youtype/awscliv2/releases).
Raw data
{
"_id": null,
"home_page": "https://youtype.github.io/awscliv2/",
"name": "awscliv2",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": "awscli, awscliv2, wrapper",
"author": "Vlad Emelianov",
"author_email": "vlad.emelianov.nz@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a2/1d/98a80461aad567164033e99780d31165626e57c8a86e668077f80e512a5e/awscliv2-2.3.1.tar.gz",
"platform": null,
"description": "# AWS CLI v2 for Python\n\n[![PyPI - awscliv2](https://img.shields.io/pypi/v/awscliv2.svg?color=blue&label=awscliv2)](https://pypi.org/project/awscliv2)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/awscliv2.svg?color=blue)](https://pypi.org/project/awscliv2)\n[![PyPI - Downloads](https://static.pepy.tech/badge/awscliv2)](https://pepy.tech/project/awscliv2)\n\nWrapper for [AWS CLI v2](https://awscli.amazonaws.com/v2/documentation/api/latest/index.html).\n\n- [AWS CLI v2 for Python](#aws-cli-v2-for-python)\n - [Features](#features)\n - [Before you start](#before-you-start)\n - [Installation](#installation)\n - [Usage](#usage)\n - [From command line](#from-command-line)\n - [Docker fallback](#docker-fallback)\n - [Extra commands](#extra-commands)\n - [As a Python module](#as-a-python-module)\n - [Development](#development)\n - [How to help](#how-to-help)\n - [Versioning](#versioning)\n - [Latest changes](#latest-changes)\n\n## Features\n\n- No dependency hell, like with original [awscli](https://pypi.org/project/awscli/)\n- Can install and update `awscliv2` binaries\n- Provides access to all AWS services\n- Has Python interface `awscliv2.api.AWSAPI`\n\n## Before you start\n\n- This is not an official AWS CLI v2 application, [rant there](https://github.com/aws/aws-cli/issues/4947)\n- Check the source code of this app, as you are working with sensitive data\n- By default this app uses [amazon/aws-cli](https://hub.docker.com/r/amazon/aws-cli) Docker image\n- To use [binaries for your OS](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html), run `awsv2 --install`\n- Cross-check the source code again, probably I want to\n [steal your credentials](https://blog.sonatype.com/python-packages-upload-your-aws-keys-env-vars-secrets-to-web)!\n\n## Installation\n\n```bash\npython -m pip install awscliv2\n```\n\nYou can add an alias to your `~/.bashrc` or `~/.zshrc` to use it as a regular `AWS CLI v2`\n\n```bash\nalias aws='awsv2'\n```\n\n## Usage\n\n### From command line\n\nInstall `AWS CLI v2`:\n\n```bash\n# do not worry if this fails, you can still use awsv2 if you have docker installed\nawsv2 --install\n```\n\nConfigure default profile if needed:\n\n```bash\nAWS_ACCESS_KEY_ID='my-access-key'\nAWS_SECRET_ACCESS_KEY='my-secret-key'\n\n# --configure <profile_name> <aws_access_key_id> <aws_secret_access_key> [<aws_session_token>]\nawsv2 --configure default ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}\nawsv2 configure set region us-west-1\n```\n\nUse `AWS CLI` as usual:\n\n```bash\n# alias for\n# docker run --rm -i -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli $@\nawsv2 s3 ls\n\n# or as a python module\npython -m awscliv2 s3 ls\n```\n\nAlso, you can check [scripts/example.sh](https://github.com/youtype/awscliv2/blob/main/scripts/example.sh)\n\n### Docker fallback\n\nUnless you run `awsv2 --install` once, application will use [amazon/aws-cli](https://hub.docker.com/r/amazon/aws-cli) Docker image. The image is not ideal, and it uses `root` user, so fix downloaded file permissions manually. Or just run `awsv2 --install`\n\nUpdate it with `docker pull amazon/aws-cli`.\n\nContainer uses two volumes:\n\n- `$HOME/.aws` -> `/root/.aws` - credentials and config store\n- `$(cwd)` -> `/aws` - Docker image workdir\n\n### Extra commands\n\n`awscliv2` contains a few commands to make your life easier, especially in CI or any non-TTY environment.\n\n- `awsv2 -U/--update/--install` - Install `AWS CLI v2`\n- `awsv2 --configure <profile_name> <aws_access_key_id> <aws_secret_access_key> [<aws_session_token>] [<region>]` - set profile in `~/.aws/credentials`\n- `awsv2 --assume-role <profile_name> <source_profile> <role_arn>` - create a new profile with assume role credentials\n- `awsv2 -V/--version` - Output `awscliv2` and `AWS CLI v2` versions\n\n### As a Python module\n\nBasic usage\n\n```python\nfrom awscliv2.api import AWSAPI\nfrom awscliv2.exceptions import AWSCLIError\n\naws_api = AWSAPI()\n\ntry:\n output = aws_api.execute([\"s3\", \"ls\"])\nexcept AWSCLIError as e:\n print(f\"Something went wrong: {e}\")\nelse:\n print(output)\n```\n\nInstall binaries for your OS from Python\n\n```python\nfrom awscliv2.installers import install_multiplatform\n\ninstall_multiplatform()\n```\n\nYou can also set credentials or assume roles\n\n```python\nfrom awscliv2.api import AWSAPI\n\naws_api = AWSAPI()\n\naws_api.set_credentials(\n profile_name=\"my_profile\",\n aws_access_key_id=\"access_key\",\n aws_secret_access_key=\"secret_key\",\n region=\"us-east-1\",\n)\naws_api.assume_role(\n profile_name=\"my_profile\",\n source_profile=\"source_profile\",\n role_arn=\"role_arn\",\n)\n```\n\n## Development\n\n- Install [poetry](https://python-poetry.org/)\n- Run `poetry install`\n- Use `black` formatter in your IDE\n\n## How to help\n\n- Ping AWS team to release an official PyPI package\n- Share your experience in issues\n\n## Versioning\n\n`awscliv2` version follows [PEP 440](https://www.python.org/dev/peps/pep-0440/).\n\n## Latest changes\n\nFull changelog can be found in [Releases](https://github.com/youtype/awscliv2/releases).\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Wrapper for AWS CLI v2",
"version": "2.3.1",
"project_urls": {
"Bug Tracker": "https://github.com/youtype/awscliv2/issues",
"Documentation": "https://awscliv2.readthedocs.io/en/latest/",
"Homepage": "https://youtype.github.io/awscliv2/",
"Repository": "https://github.com/youtype/awscliv2",
"Source": "https://github.com/youtype/awscliv2"
},
"split_keywords": [
"awscli",
" awscliv2",
" wrapper"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ddb6be25b1ddf45e9c73fdd26e95daa2892742932dc7c602844822c1fff5dab3",
"md5": "35edfe433f33dbdda3e44261eb1d7d8f",
"sha256": "ab4bc182b0cfba0f6872061cbb1bd6abfbfc1e4016fa5de40b7a2d564eca267e"
},
"downloads": -1,
"filename": "awscliv2-2.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "35edfe433f33dbdda3e44261eb1d7d8f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 13510,
"upload_time": "2024-09-04T10:19:17",
"upload_time_iso_8601": "2024-09-04T10:19:17.467578Z",
"url": "https://files.pythonhosted.org/packages/dd/b6/be25b1ddf45e9c73fdd26e95daa2892742932dc7c602844822c1fff5dab3/awscliv2-2.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a21d98a80461aad567164033e99780d31165626e57c8a86e668077f80e512a5e",
"md5": "e3450f7f39dc74e763554cb61b44b642",
"sha256": "5fbbf104bcd7796b7af104bd6af99f6e153208883399aeff830d97b3ea34f7ae"
},
"downloads": -1,
"filename": "awscliv2-2.3.1.tar.gz",
"has_sig": false,
"md5_digest": "e3450f7f39dc74e763554cb61b44b642",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 12090,
"upload_time": "2024-09-04T10:19:18",
"upload_time_iso_8601": "2024-09-04T10:19:18.774622Z",
"url": "https://files.pythonhosted.org/packages/a2/1d/98a80461aad567164033e99780d31165626e57c8a86e668077f80e512a5e/awscliv2-2.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 10:19:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "youtype",
"github_project": "awscliv2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "awscliv2"
}