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

Make aws access ids optional to support assume role authencation #1629

Merged
merged 3 commits into from
Jan 24, 2024
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
6 changes: 4 additions & 2 deletions stix_shifter_modules/aws_athena/configuration/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"auth": {
"type" : "fields",
"aws_access_key_id": {
"type": "password"
"type": "password",
"optional": true
},
"aws_iam_role": {
"type": "password",
Expand All @@ -60,7 +61,8 @@
"optional": true
},
"aws_secret_access_key": {
"type": "password"
"type": "password",
"optional": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ def __init__(self, connection, configuration):
self.connection = connection
self.configuration = configuration
self.session = None
# TODO: verify
self.verify = False


async def getSession(self):
if self.session is None:
Expand All @@ -28,8 +25,7 @@ async def getSession(self):
session = aioboto3.Session()
async with session.client('sts',
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
verify=self.verify
aws_secret_access_key=aws_secret_access_key
) as client:
role_to_assume_arn = auth.get('aws_iam_role')
assume_role_external_id = auth.get('aws_assume_role_external_id')
Expand Down Expand Up @@ -72,7 +68,7 @@ async def getSession(self):
async def makeRequest(self, api_name, method, **kwargs):
response = None
session = await self.getSession()
async with session.client(api_name, verify=self.verify) as cl:
async with session.client(api_name) as cl:
call = getattr(cl, method.lower())
response = await call(**kwargs)

Expand All @@ -81,7 +77,7 @@ async def makeRequest(self, api_name, method, **kwargs):
async def getPaginatedResult(self, api_name, method, **kwargs):
result_response_list = []
session = await self.getSession()
async with session.client(api_name, verify=self.verify) as cl:
async with session.client(api_name) as cl:
paginator = cl.get_paginator(method)
get_query_response = paginator.paginate(**kwargs)
async for page in get_query_response:
Expand Down