Skip to main content

Hacksaws

Checks PyPI version Python versions License

Hacksaws is a command-line utility for AWS profiles that use dynamic authentication methods such as multi-factor authentication (MFA). It replaces a profile's long-term access key and secret with temporary session credentials, while storing the long-term credentials in a local backup until the next login or logout.

Only MFA-based dynamic login is currently supported. Hacksaws supports Python 3.13 and 3.14.

Installation

Install Hacksaws as an isolated command-line tool with uv:

uv tool install hacksaws

As a fallback, install it into the active Python environment with pip:

python -m pip install hacksaws

Usage

Log in with MFA by supplying an AWS profile and the current MFA code:

hacksaws mfa login <PROFILE_NAME> <MFA_CODE>

The --lifespan option changes how long the temporary session remains valid. The default is 12 hours (--lifespan=43200 seconds). AWS allows at most 24 hours, and the profile's role or account policy may set a lower maximum.

Hacksaws can also log Docker into Amazon ECR in the profile's default region:

hacksaws mfa login <PROFILE_NAME> <MFA_CODE> --ecr

Use --ecr-region more than once to add regions. The profile's primary region is processed first, followed by each additional region once in the order provided:

hacksaws mfa login <PROFILE_NAME> <MFA_CODE> \
  --ecr \
  --ecr-region=eu-central-1 \
  --ecr-region=us-west-2 \
  --ecr-region=ca-central-1

Log out of the AWS profile and restore its long-term credentials:

hacksaws mfa logout <PROFILE_NAME>

Add --ecr to the logout command to log Docker out of the configured ECR registries as well:

hacksaws mfa logout <PROFILE_NAME> --ecr

Use --directory to select a different AWS configuration directory:

hacksaws mfa login <PROFILE_NAME> <MFA_CODE> --directory=/path/to/aws

For directories in the ~/.aws-<NAME> form, --name is shorthand for choosing the named account directory:

hacksaws mfa login <PROFILE_NAME> <MFA_CODE> --name=sandbox

The action aliases in and out, the directory alias --dir, and the account name alias --account-name remain available.

Requiring MFA

The repository includes an example IAM policy that lets users manage their own credentials while requiring MFA for other AWS operations.

AWS provides further guidance:

Development

Install the locked Python and Node.js development dependencies:

uv sync --locked --all-groups
npm ci

Format the repository:

uv run task format

Run the same non-mutating quality and test checks used by GitHub Actions:

uv run task check

Run an individual check when iterating:

uv run task lint
uv run task test
uv run task build

Release process

Publishing is handled by the publish.yaml GitHub Actions workflow and PyPI trusted publishing.

  1. Update project.version in pyproject.toml.
  2. Run uv lock, npm ci, and uv run task check.
  3. Build locally with uv build and inspect the wheel and source distribution.
  4. Merge the version change to main.
  5. Create and push a v<version> tag, such as v0.3.0.

The workflow verifies that the tag exactly matches the project version before it builds and publishes. The repository's pypi environment must be configured as a trusted publisher for owner rocketboosters, repository hacksaws, workflow publish.yaml, and environment pypi.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hacksaws-0.3.1.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

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

hacksaws-0.3.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file hacksaws-0.3.1.tar.gz.

File metadata

  • Download URL: hacksaws-0.3.1.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hacksaws-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7c9cdb9a1d8f0441a626091a3719b8124d684b7cc28c2ea5f5e8aa1acd23abe4
MD5 7df1d36f925dc78d005b42c239bc3386
BLAKE2b-256 af80066acf78cda7065d1f7a3949250f2a0542ea833c144567263d8335df3b10

See more details on using hashes here.

Provenance

The following attestation bundles were made for hacksaws-0.3.1.tar.gz:

Publisher: publish.yaml on rocketboosters/hacksaws

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hacksaws-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: hacksaws-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hacksaws-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8db1d1df5fc356f9bf72fe125b2f858e69d54398cebf5fcc98c585a759abf5f
MD5 b02e3df6a7fb950f20b86832b3241b4b
BLAKE2b-256 14ca02b78c120168dabbe31637d9bdf2162fb3d2b2e6948427170301f4eaca34

See more details on using hashes here.

Provenance

The following attestation bundles were made for hacksaws-0.3.1-py3-none-any.whl:

Publisher: publish.yaml on rocketboosters/hacksaws

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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