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.14.tar.gz (11.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.14-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aws_sso_tool-0.1.14.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

Hashes for aws_sso_tool-0.1.14.tar.gz
Algorithm Hash digest
SHA256 7e86c1a1199a75dea4cd10429561f4e383c590c2b2a94faa49e5907272f6ab68
MD5 9781e5924df967b93db78761ffdf6f2d
BLAKE2b-256 242181d17fbf9c4da7f940953de2ba2ee892768141b9fb376d6bb43275b6fd0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aws_sso_tool-0.1.14-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

Hashes for aws_sso_tool-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f556a9e21dc97bbc6ba07ad6731c9779521ff9a51af73a302a715bfc312c23
MD5 cc0303fcad7e4a8f74c65cd6b8162387
BLAKE2b-256 6ca7d6b8d2611ece868d32fd398ea32320584d5378dc04378dd31275594254b7

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