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 a container engine into Amazon ECR in the profile's default region. Docker is used by default:

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

Select Podman by adding --podman. The option chooses the container engine but does not enable ECR by itself, so use it together with --ecr:

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

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 the same --podman selection when logging Podman out:

hacksaws mfa logout <PROFILE_NAME> --ecr --podman

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. Each successful release publishes the wheel and source distribution to PyPI, then creates a GitHub Release for the same tag with those exact artifacts attached.

  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.2.

The workflow verifies that the tag exactly matches the project version before it builds once, publishes the resulting artifacts to PyPI, and creates the GitHub Release only after PyPI succeeds. 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.2.tar.gz (40.0 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.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hacksaws-0.3.2.tar.gz
  • Upload date:
  • Size: 40.0 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.2.tar.gz
Algorithm Hash digest
SHA256 ef375a3a2e124bd5acb1d28d697b86b3a86241b3a86b72f2a680bbaa692c1447
MD5 73628a2e3abc755f58094d2ac59482ac
BLAKE2b-256 80a7b42bce951b7e861f7123c3f2877c9007575509aa27ecd8d4f4a9b1f883c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hacksaws-0.3.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: hacksaws-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a12a688149864ae3358e18378ab173dd861c73601d192515eae1458c653e7d4
MD5 9bae8eacf8aaaab7a35817f3828fb77c
BLAKE2b-256 0ac57acc154c39cd9ad8eb764fedf144b4e526ef48eb2550162522df6ca1173b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hacksaws-0.3.2-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