Skip to main content

CLI tool to simplify AWS SSO login and operations

Project description

<title>AWS SSO Tool</title>

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

  1. Set the Default AWS Profile

    You can set or change the default AWS profile to be used for SSO authentication:

    aws-sso-tool --set-default

    This command will prompt you to enter your AWS profile name.

  2. <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 &lt;file_path&gt; &lt;bucket_name&gt;</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 &lt;file_path&gt; &lt;bucket_name&gt; --object-name &lt;object_name&gt;</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 &lt;bucket_name&gt; &lt;object_name&gt; &lt;file_path&gt;</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 &lt;instance_id&gt;</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 &lt;instance_id&gt;</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

aws_sso_tool-0.1.11.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_sso_tool-0.1.11-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file aws_sso_tool-0.1.11.tar.gz.

File metadata

  • Download URL: aws_sso_tool-0.1.11.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aws_sso_tool-0.1.11.tar.gz
Algorithm Hash digest
SHA256 d2e0d9f9308bfb45bbba30ca02523b2fb10c2a18cd0df7f5ce0aa2b1516162d1
MD5 4c961732fe14c7f4b4a0295aed3bb520
BLAKE2b-256 42e28e4a38d6b0d1611b3bd754c8a2780939071c8f684c6735d5315abfb954b0

See more details on using hashes here.

File details

Details for the file aws_sso_tool-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: aws_sso_tool-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aws_sso_tool-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 26ddcb53460e66885179f1ddc1c75e8e23a1cf533d4b50882f0465dad5669321
MD5 a12670114c95a7a39726677022064bfa
BLAKE2b-256 8732d3e644bb9c893e25dfa68d46e7ae1ab62cae4c41ba25bbf9f8d21a3eaf1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page