CLI tool to simplify AWS SSO login and operations
Project description
AWS SSO Tool
A simple CLI tool to help developers connect to AWS via SSO and perform basic AWS operations, such as listing S3 buckets, uploading and downloading files, and managing EC2 instances. This tool ensures that AWS SSO tokens are automatically renewed when needed, streamlining the AWS login process for developers.
Features
- Automatically handle AWS SSO login and token management.
- List S3 buckets in your AWS account.
- Upload files to and download files from S3.
- List EC2 instances and manage their state (start/stop).
Installation
To install the aws-sso-tool, you can use pip:
pip install aws-sso-tool
This will install the tool and its dependencies.
Usage
Once the tool is installed, you can access it from the command line using the aws-sso-tool command. Below are the common commands and options available:
Basic Commands
- Set the Default AWS Profile
You can set or change the default AWS profile to be used for SSO authentication:
aws-sso-tool --set-defaultThis command will prompt you to enter your AWS profile name.
<li><strong>Set or Change the AWS Region</strong>
<p>You can set the default AWS region for operations:</p>
<pre><code>aws-sso-tool --set-region</code></pre>
<p>The command will fetch a list of available regions from AWS and prompt you to choose one.</p>
</li>
<li><strong>List S3 Buckets</strong>
<p>List all S3 buckets in the connected AWS account:</p>
<pre><code>aws-sso-tool --list-buckets</code></pre>
<p>This will display all the S3 buckets under the connected AWS account.</p>
</li>
<li><strong>Upload a File to S3</strong>
<p>Upload a file to a specific S3 bucket:</p>
<pre><code>aws-sso-tool --upload-file <file_path> <bucket_name></code></pre>
<p>Optionally, you can provide an <code>object_name</code> to set the name of the file in S3:</p>
<pre><code>aws-sso-tool --upload-file <file_path> <bucket_name> --object-name <object_name></code></pre>
</li>
<li><strong>Download a File from S3</strong>
<p>Download a file from a specific S3 bucket:</p>
<pre><code>aws-sso-tool --download-file <bucket_name> <object_name> <file_path></code></pre>
<p>This command will download the file from S3 to the specified path.</p>
</li>
<li><strong>List EC2 Instances</strong>
<p>List all EC2 instances in the selected AWS region:</p>
<pre><code>aws-sso-tool --list-instances</code></pre>
</li>
<li><strong>Start an EC2 Instance</strong>
<p>Start an EC2 instance by specifying its instance ID:</p>
<pre><code>aws-sso-tool --start-instance <instance_id></code></pre>
</li>
<li><strong>Stop an EC2 Instance</strong>
<p>Stop an EC2 instance by specifying its instance ID:</p>
<pre><code>aws-sso-tool --stop-instance <instance_id></code></pre>
</li>
Configuration
AWS Profile
The tool allows you to set the AWS profile you want to use with SSO. When you first run the tool, you'll be prompted to set the AWS profile. The profile will be saved to a local file and used as the default for subsequent operations.
AWS Region
Similarly, the tool will ask for your preferred AWS region the first time you run it. You can set or change the region using the --set-region command at any time.
Automatic SSO Token Renewal
The tool automatically checks the SSO token expiration and renews it if needed. It will only prompt for a login via the browser when necessary.
Error Handling
The tool handles various errors, such as:
- Invalid AWS credentials: If the AWS SSO token is expired or invalid, the tool will automatically attempt to renew it.
- Connection issues: If there is an issue connecting to AWS, the error will be logged, and the user will be informed.
- File not found: For file operations (upload/download), if the specified file path is invalid, the tool will log the error and inform the user.
Development
To install the tool in development mode:
pip install -e .
Running Tests
You can run the tests using pytest:
pytest tests/
This will execute all the unit tests for the tool.
Contributing
Contributions are welcome! If you'd like to contribute, feel free to fork the repository and submit a pull request. Please make sure to write tests for any new functionality.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aws_sso_tool-0.1.13.tar.gz.
File metadata
- Download URL: aws_sso_tool-0.1.13.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ead9da132079dc8f30a8942320f933581b5b739ae603bda78a60b0ae5a9c9a
|
|
| MD5 |
76b6ffb869a4fb5032340715af7b2d2b
|
|
| BLAKE2b-256 |
3e4b399f183b85f95d2d7457cf74e2610597c96ec6a6633509439be2598a7d81
|
File details
Details for the file aws_sso_tool-0.1.13-py3-none-any.whl.
File metadata
- Download URL: aws_sso_tool-0.1.13-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fd67998d997531e87a7d06597a6d849f37bc203ea213112f682137279c65f2c
|
|
| MD5 |
727e1702e0bfba085e01251a376934e6
|
|
| BLAKE2b-256 |
5f5f1d6f7b10a5c08bd93dd72a40337f0f2bfada0302681ee4a5d4a3c64c63c6
|