Skip to content

Commit

Permalink
Drop boto3 dependency
Browse files Browse the repository at this point in the history
Removing boto3 because it is completely unnecessary, and incompatible
with awscliv2 (See link below). botocore is being used instead where
boto3 was used before.

boto/boto3#2571

Fixes techservicesillinois#37
Fixes techservicesillinois#44
  • Loading branch information
ddriddle committed Mar 23, 2021
1 parent e2b2a69 commit c67d68f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Changed

* invalid selection now issues a fatal error message `#71`_

Fixed
`````
* drop boto3 dependency that conflicts with awscliv2 `#73`_

`0.2b1`_ 2021-02-04
---------------------

Expand Down Expand Up @@ -87,3 +91,4 @@ Fixed
.. _#64: https://github.com/techservicesillinois/awscli-login/pull/64
.. _#66: https://github.com/techservicesillinois/awscli-login/pull/66
.. _#71: https://github.com/techservicesillinois/awscli-login/pull/71
.. _#73: https://github.com/techservicesillinois/awscli-login/pull/73
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def clean_scheme(version):
python_requires='>=3.5',
install_requires=[
'awscli',
'boto3',
'botocore',
'daemoniker',
'keyring',
Expand Down
9 changes: 4 additions & 5 deletions src/awscli_login/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from functools import wraps
from typing import Optional

import boto3

from botocore.session import Session
from botocore import client as Client
from daemoniker import Daemonizer, SignalHandler1
from daemoniker import send, SIGINT, SIGTERM, SIGABRT

Expand Down Expand Up @@ -44,7 +43,7 @@
logger = logging.getLogger(__package__)


def save_sts_token(session: Session, client: boto3.client, saml: str,
def save_sts_token(session: Session, client: Client, saml: str,
role: Role, duration: int = 0) -> datetime:
params = dict(
RoleArn=role[1],
Expand All @@ -64,7 +63,7 @@ def save_sts_token(session: Session, client: boto3.client, saml: str,
return save_credentials(session, token)


def daemonize(profile: Profile, session: Session, client: boto3.client,
def daemonize(profile: Profile, session: Session, client: Client,
role: Role, expires: datetime) -> bool:
with Daemonizer() as (is_setup, daemonizer):
is_parent, profile, session, client, role, expires = daemonizer(
Expand Down Expand Up @@ -179,7 +178,7 @@ def main(profile: Profile, session: Session):
logger.warn("Logged out: ignoring --force-refresh.")

try:
client = boto3.client('sts')
client = session.create_client('sts')

# Exit if already logged in
profile.raise_if_logged_in()
Expand Down
5 changes: 2 additions & 3 deletions src/awscli_login/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Dict, List, Tuple

from awscli.customizations.configure.set import ConfigureSetCommand
from botocore.utils import parse_timestamp
from botocore.session import Session

from .const import ERROR_INVALID_PROFILE_ROLE
Expand Down Expand Up @@ -130,9 +131,7 @@ def save_credentials(session: Session, token: Dict) -> datetime:
_aws_set(session, 'aws_security_token', creds['SessionToken'])
logger.info("Saved temporary STS credentials to profile: " + profile)

assert isinstance(creds['Expiration'], datetime), \
"Amazon returned bad Expiration!"
return creds['Expiration']
return parse_timestamp(creds['Expiration'])


def file2bytes(filename: str) -> bytes:
Expand Down
3 changes: 1 addition & 2 deletions src/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import unittest

from datetime import datetime, timezone
from io import StringIO
from multiprocessing import get_start_method
from os.path import isfile
Expand Down Expand Up @@ -33,7 +32,7 @@ def token(akey: str, skey: str, stoken: str) -> Dict[str, Dict[str, Any]]:
'AccessKeyId': akey,
'SecretAccessKey': skey,
'SessionToken': stoken,
'Expiration': datetime.now(timezone.utc)
'Expiration': '2021-02-11T00:42:09Z'
}
}

Expand Down

0 comments on commit c67d68f

Please sign in to comment.