Skip to content

Commit

Permalink
Converting to Poetry
Browse files Browse the repository at this point in the history
Honestly easier at this point than getting the existing setup working again.

Signed-off-by: Geoffrey Wiseman <geoffrey.wiseman@codiform.com>
  • Loading branch information
geoffreywiseman committed Mar 30, 2023
1 parent c5d6a8d commit e07f934
Show file tree
Hide file tree
Showing 15 changed files with 861 additions and 323 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: CI

on:
push:
branches: [master]
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches: [ master ]

jobs:

Expand All @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: [ '3.9', '3.10', '3.11' ]
name: Build w/ Python ${{ matrix.python-version }}

steps:
Expand All @@ -24,11 +24,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
poetry install
- name: Test
run: |
pytest
poetry run pytest
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

22 changes: 0 additions & 22 deletions Pipfile

This file was deleted.

77 changes: 34 additions & 43 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
AWS Whitelist
=============
# AWS Whitelist

.. image:: https://github.com/geoffreywiseman/awswl/actions/workflows/ci.yml/badge.svg
:target: https://github.com/geoffreywiseman/awswl/actions/workflows/ci.yml
.. image:: http://pepy.tech/badge/awswl
:target: http://pepy.tech/count/awswl
[![ci](https://github.com/geoffreywiseman/awswl/actions/workflows/ci.yml/badge.svg)](https://github.com/geoffreywiseman/awswl/actions/workflows/ci.yml)
[![downloads](http://pepy.tech/badge/awswl)](http://pepy.tech/count/awswl)

A small tool to make it pretty simple to add and remove ip addresses (or CIDR blocks) from an AWS
security group. This acts like a sort of oversimplified VPN, where you can quickly give yourself
SSH access to a project as you move about from network to network.

You can read about recent changes in the CHANGELOG_.
You can read about recent changes in the [CHANGELOG](CHANGELOG.md).

.. _CHANGELOG: CHANGELOG.md

Better Solutions
----------------
## Better Solutions

Anyone who knows enough to use a tool like this likely knows that there are better options
available, from hardware VPNs to software VPNs hosted on an EC2 instance, and so forth. If you
Expand All @@ -25,84 +20,80 @@ look at the better options, and see if they fit your needs.
Of course, most of those other options require you to get additional hardware or software resources
involved and might come with costs. I understand, that's why I made a little tool to make do.

Installing
----------
## Installing

This is a python tool, packaged as a python module, so you should be able to just run

.. code-block:: bash
$ pip install awswl
```bash
pip install awswl
```

Of course, if you don't know what a python module is, or you don't have python and pip installed,
you may have additional work ahead of you.

The ``awswl`` module should be compatible with both python2 and python3; I have Travis building it
for Python 2.7, 3.5, 3.6, and 3.7.
Now that Python2 is largely a relic of the past, I'm focused on supporting Python 3 only. The current CI build is for Python 3.9+.

Usage
-----
## Usage

If you want usage help at the command line, try:

.. code-block:: bash
$ awswl --help
```bash
awswl --help
```

You can list the IP address blocks that are authorized, including which ip address is current:

.. code-block:: bash
$ awswl --list
```bash
awswl --list
```

Authorize your current IP Address:

.. code-block:: bash
$ awswl --add-current
```bash
awswl --add-current
```

Remove authorization for your current IP:

.. code-block:: bash
$ awswl --remove-current
```bash
awswl --remove-current
```

Authorize a manually-specified CIDR block:

.. code-block:: bash
$ awswl --add 192.168.0.0/24
```bash
awswl --add 192.168.0.0/24
```

Remove authorization for a manually-specified CIDR block:

.. code-block:: bash
$ awswl --remove 192.168.0.0/24
```bash
awswl --remove 192.168.0.0/24
```

For each of these commands, you need to tell awswl which security group to use, which you can do
with the ``--sgid`` command-line option or using an environment variable.


Integration
-----------
## Integration

In order to get your current ip address, ``--list``, ``--add-current`` and ``--remove-current``
will make a request to ``api.ipify.org``. I may `add a switch`_ to disable that for the privacy-
inclined, but feel free to vote for it.

.. _add a switch: https://github.com/geoffreywiseman/awswl/issues/3


Environment
-----------
## Environment

All of these require you to have AWS credentials set up in advance, stored in
``~/.aws/credentials``, and if you need to use a profile, you can configure it with
``AWS_PROFILE``. If you want to identify the security group using a command-line variable so that
you don't have to put it into each command invocation, you can put it in ``AWSWL_SGID``.


Edge Cases
----------
## Edge Cases

For simple use cases, ``awswl`` does everything I want it to do, but it's currently a pretty thin
wrapper over the AWS API for authorizing and revoking access via security groups, and as a result
it doesn't do much pre-processing or validating of your requests. There are cases that it doesn't
Expand Down
6 changes: 0 additions & 6 deletions awswl/commands.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import str

import boto3
Expand Down
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
poetry build

test:
poetry run pytest

0 comments on commit e07f934

Please sign in to comment.