From 05b8185d00c887ebb3a29164db4e7efc4f5160ea Mon Sep 17 00:00:00 2001 From: Karol Pucynski Date: Tue, 3 Dec 2019 18:18:35 +0100 Subject: [PATCH 1/4] small fixes --- bin/aws-env-update.py | 4 ++-- bin/aws-list-ec2.py | 2 +- bin/aws-roll-keys.py | 2 +- requirements.txt | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/aws-env-update.py b/bin/aws-env-update.py index 1a8ac17..ce063e7 100755 --- a/bin/aws-env-update.py +++ b/bin/aws-env-update.py @@ -19,14 +19,14 @@ def get_args(): '''This function parses and return arguments passed in''' available_envs = list( map(lambda file: re.sub(r"env.(.*).conf.asc", r"\1", file), - filter(lambda file: file.startswith("env"), + filter(lambda file: file.endswith(".asc"), os.listdir(aws_config_dir)))) parser = argparse.ArgumentParser(__file__, formatter_class=argparse.RawDescriptionHelpFormatter, description=('''\ Simple script that will pick up gpg encrypted files from ~/.aws and save them in the ${HOME}/.aws/credentials file. -Usage:\n\n\t$ awsenv test \n'''), +Usage:\n\n\t$ ''' + os.path.basename(__file__) + ''' [options] [parameters] \n'''), epilog="Copyright (C) 2016 Bart Jakubowski ") file_group = parser.add_mutually_exclusive_group(required=True) file_group.add_argument("-e", "--env", help="environment name (conflicts with --file)", choices=available_envs) diff --git a/bin/aws-list-ec2.py b/bin/aws-list-ec2.py index b642863..af4c53f 100755 --- a/bin/aws-list-ec2.py +++ b/bin/aws-list-ec2.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import sys import getopt diff --git a/bin/aws-roll-keys.py b/bin/aws-roll-keys.py index ce44ee9..bf89eaa 100755 --- a/bin/aws-roll-keys.py +++ b/bin/aws-roll-keys.py @@ -99,7 +99,7 @@ def send(srv, sendto, data): def main(): available_envs = list( map(lambda file: re.sub(r"^env.(.*).conf.asc$", r"\1", file), - filter(lambda file: file.startswith("env"), + filter(lambda file: file.endswith(".asc"), os.listdir(aws_config_dir)))) parser = argparse.ArgumentParser( description="Rolls AWS IAM Access Keys for all or specified env(s)", diff --git a/requirements.txt b/requirements.txt index 88e0804..3a8867d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ -argparse -boto3 +python-gnupg>=0.4.6 +argparse>=1.4.0 +boto3>=1.10.8 python-gnupg>=0.4.6 From 1ad60cf2b67b6d9c6ee7f4be8c180aaa7a36a0c9 Mon Sep 17 00:00:00 2001 From: Karol Pucynski Date: Tue, 3 Dec 2019 22:00:06 +0100 Subject: [PATCH 2/4] awsenv -> aws-env-update.py --- README.rst | 14 +++++++------- bin/aws_tools_completion.bash | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index dc29020..b7bef86 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ Switching between AWS accounts: :: - $ awsenv test + $ aws-env-update.py test $ aws s3 ls ...list of S3 objects on TEST environment... @@ -31,7 +31,7 @@ Switching between AWS accounts: ### AWS_ACCESS_KEY_ID=AKIAJPVK7VGH6CBZT5EQ ### AWS_ENV=test - $ awsenv prod + $ aws-env-update.py prod $ aws s3 ls ...list of S3 objects on PROD environment... @@ -45,7 +45,7 @@ Renewing AWS API access keys: :: - $ awsenv prod + $ aws-env-update.py prod ### Explanation: ### $ env | grep AWS @@ -55,7 +55,7 @@ Renewing AWS API access keys: $ awsroll prod Rolled key for env prod: AccessKeyId=****************ZKQFQ; CreateDate=2018-11-14 13:10:04+00:00 - $ awsenv prod + $ aws-env-update.py prod ### Explanation: ### $ env | grep AWS @@ -192,20 +192,20 @@ Autocompletion: :: - $ awsenv + $ aws-env-update.py prod stage test Use TEST access keys: :: - $ awsenv test + $ aws-env-update.py test Unset AWS access keys for current shell: :: - $ awsenv unset + $ aws-env-update.py unset Rotate PROD access keys: diff --git a/bin/aws_tools_completion.bash b/bin/aws_tools_completion.bash index 3160ef7..9c068f2 100644 --- a/bin/aws_tools_completion.bash +++ b/bin/aws_tools_completion.bash @@ -25,7 +25,7 @@ function awsroll() { aws-roll-keys.py -a -e "${1:-all}" } -function awsenv() { +function aws-env-update.py() { if [[ $1 == "unset" ]]; then unset AWS_ENV AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY else @@ -33,4 +33,4 @@ function awsenv() { fi } -complete -F __aws_envs awsenv +complete -F __aws_envs aws-env-update.py From 7a4810e0e25dff4e6934944e027e067fcd64140c Mon Sep 17 00:00:00 2001 From: Karol Pucynski Date: Tue, 3 Dec 2019 22:00:20 +0100 Subject: [PATCH 3/4] github action --- .github/workflows/tox.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/tox.yml diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml new file mode 100644 index 0000000..f5124f5 --- /dev/null +++ b/.github/workflows/tox.yml @@ -0,0 +1,24 @@ +name: Python package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [2.7, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Test with tox + run: tox From 378fa606cdc40e2916f171938f26d95c99069b3a Mon Sep 17 00:00:00 2001 From: Karol Pucynski Date: Wed, 10 Jun 2020 11:02:05 +0200 Subject: [PATCH 4/4] requirements.txt update --- requirements.in | 3 +++ requirements.txt | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 requirements.in diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..88e0804 --- /dev/null +++ b/requirements.in @@ -0,0 +1,3 @@ +argparse +boto3 +python-gnupg>=0.4.6 diff --git a/requirements.txt b/requirements.txt index 3a8867d..3fdaa1f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,16 @@ -python-gnupg>=0.4.6 -argparse>=1.4.0 -boto3>=1.10.8 -python-gnupg>=0.4.6 +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile +# +argparse==1.4.0 # via -r requirements.in +boto3==1.13.26 # via -r requirements.in +botocore==1.16.26 # via boto3, s3transfer +docutils==0.15.2 # via botocore +jmespath==0.10.0 # via boto3, botocore +python-dateutil==2.8.1 # via botocore +python-gnupg==0.4.6 # via -r requirements.in +s3transfer==0.3.3 # via boto3 +six==1.15.0 # via python-dateutil +urllib3==1.25.9 # via botocore