forked from Tomme/dbt-athena
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…upport configured AWS profile when calling boto3
- Loading branch information
Marco Salazar
committed
Aug 29, 2022
1 parent
83f7756
commit 915175d
Showing
3 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import boto3.session | ||
from dbt.contracts.connection import Connection | ||
|
||
|
||
__BOTO3_SESSION__: boto3.session.Session = None | ||
|
||
|
||
def get_boto3_session(connection: Connection) -> boto3.session.Session: | ||
def init_session(): | ||
global __BOTO3_SESSION__ | ||
__BOTO3_SESSION__ = boto3.session.Session( | ||
region_name=connection.credentials.region_name, | ||
profile_name=connection.credentials.aws_profile_name, | ||
) | ||
|
||
if not __BOTO3_SESSION__: | ||
init_session() | ||
|
||
return __BOTO3_SESSION__ |