Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue #54] Fixed auth compatibility with EKS serviceAccount roles #57

Merged
merged 1 commit into from
Jan 30, 2023
Merged
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
8 changes: 6 additions & 2 deletions sqs_launcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ def __init__(self, queue=None, queue_url=None, create_queue=False, visibility_ti
"""
if not any((queue, queue_url)):
raise ValueError('Either `queue` or `queue_url` should be provided.')
if (not os.environ.get('AWS_ACCOUNT_ID', None) and
not (boto3.Session().get_credentials().method in ['iam-role', 'assume-role'])):

if (
not os.environ.get('AWS_ACCOUNT_ID', None) and
not (boto3.Session().get_credentials().method in ['iam-role', 'assume-role', 'assume-role-with-web-identity'])
):
raise EnvironmentError('Environment variable `AWS_ACCOUNT_ID` not set and no role found.')

# new session for each instantiation
self._session = boto3.session.Session()
self._client = self._session.client('sqs')
Expand Down
6 changes: 4 additions & 2 deletions sqs_listener/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def __init__(self, queue, **kwargs):
)
else:
boto3_session = None
if (not os.environ.get('AWS_ACCOUNT_ID', None) and
not ('iam-role' == boto3.Session().get_credentials().method)):
if (
not os.environ.get('AWS_ACCOUNT_ID', None) and
not (boto3.Session().get_credentials().method in ['iam-role', 'assume-role', 'assume-role-with-web-identity'])
):
raise EnvironmentError('Environment variable `AWS_ACCOUNT_ID` not set and no role found.')

self._queue_name = queue
Expand Down