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.12.tar.gz (10.1 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.12-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aws_sso_tool-0.1.12.tar.gz
  • Upload date:
  • Size: 10.1 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.12.tar.gz
Algorithm Hash digest
SHA256 07f3192c9a706b1a1374e1617d6492f1888eafcde9c477c4ce16c420a8450f6a
MD5 aedd84cae85caa5d000ec1291cae40e8
BLAKE2b-256 6f30f8980deb52c5867ac121bea36bf07ecefc775b550e85cf224aaf5a256b38

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aws_sso_tool-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 cf2a2e225cfa58b0030db29a8d7d8a24c7207016071ef8ba6d641825f8bd83a5
MD5 faa1edaed3e161a92f10ce618d65bae5
BLAKE2b-256 845852ea776762d49f57f5c6af9f26c9772458c2e68aef6966a005508eefd9ad

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