Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Switching between AWS accounts:

::

$ awsenv test
$ aws-env-update.py test
<test> $ aws s3 ls
...list of S3 objects on TEST environment...

Expand All @@ -31,7 +31,7 @@ Switching between AWS accounts:
### AWS_ACCESS_KEY_ID=AKIAJPVK7VGH6CBZT5EQ
### AWS_ENV=test

<test> $ awsenv prod
<test> $ aws-env-update.py prod
<prod> $ aws s3 ls
...list of S3 objects on PROD environment...

Expand All @@ -45,7 +45,7 @@ Renewing AWS API access keys:

::

$ awsenv prod
$ aws-env-update.py prod

### Explanation:
### <prod> $ env | grep AWS
Expand All @@ -55,7 +55,7 @@ Renewing AWS API access keys:

<prod> $ awsroll prod
Rolled key for env prod: AccessKeyId=****************ZKQFQ; CreateDate=2018-11-14 13:10:04+00:00
<prod> $ awsenv prod
<prod> $ aws-env-update.py prod

### Explanation:
### <prod> $ env | grep AWS
Expand Down Expand Up @@ -192,20 +192,20 @@ Autocompletion:

::

$ awsenv<TAB><TAB>
$ aws-env-update.py<TAB><TAB>
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:

Expand Down
4 changes: 2 additions & 2 deletions bin/aws-env-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bartekj@gmail.com>")
file_group = parser.add_mutually_exclusive_group(required=True)
file_group.add_argument("-e", "--env", help="environment name (conflicts with --file)", choices=available_envs)
Expand Down
2 changes: 1 addition & 1 deletion bin/aws-list-ec2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

import sys
import getopt
Expand Down
2 changes: 1 addition & 1 deletion bin/aws-roll-keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 2 additions & 2 deletions bin/aws_tools_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ 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
eval $(aws-env-update.py -x -a -e ${1})
fi
}

complete -F __aws_envs awsenv
complete -F __aws_envs aws-env-update.py
3 changes: 3 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
argparse
boto3
python-gnupg>=0.4.6
19 changes: 16 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
argparse
boto3
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