Skip to content

Commit

Permalink
keep use_interactive_session_role_for_api_calls but change the defaul…
Browse files Browse the repository at this point in the history
…t value to True
  • Loading branch information
Vincent.PAUWELS committed Nov 20, 2023
1 parent 37ef5af commit c3a8ef3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dbt/adapters/glue/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GlueCredentials(Credentials):
seed_mode: Optional[str] = "overwrite"
default_arguments: Optional[str] = None
iceberg_glue_commit_lock_table: Optional[str] = "myGlueLockTable"
use_interactive_session_role_for_api_calls: bool = False
use_interactive_session_role_for_api_calls: bool = True
lf_tags: Optional[str] = None
glue_session_id: Optional[str] = None
glue_session_reuse: Optional[bool] = False
Expand Down
27 changes: 15 additions & 12 deletions dbt/adapters/glue/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,23 @@ def convert_datetime_type(cls, agate_table, col_idx):
def get_connection(self):
connection: GlueConnectionManager = self.connections.get_thread_connection()
glueSession: GlueConnection = connection.handle
if glueSession.credentials.role_arn is not None:
if glueSession.credentials.use_interactive_session_role_for_api_calls is True:
sts_client = boto3.client('sts')
assumed_role_object = sts_client.assume_role(
RoleArn=glueSession.credentials.role_arn,
RoleSessionName="dbt"
)
credentials = assumed_role_object['Credentials']
glue_client = boto3.client("glue", region_name=glueSession.credentials.region,
aws_access_key_id=credentials['AccessKeyId'],
aws_secret_access_key=credentials['SecretAccessKey'],
aws_session_token=credentials['SessionToken'])
return glueSession, glue_client

sts_client = boto3.client('sts')
assumed_role_object = sts_client.assume_role(
RoleArn=glueSession.credentials.role_arn,
RoleSessionName="dbt"
)
credentials = assumed_role_object['Credentials']

client = boto3.client("glue", region_name=glueSession.credentials.region,
aws_access_key_id=credentials['AccessKeyId'],
aws_secret_access_key=credentials['SecretAccessKey'],
aws_session_token=credentials['SessionToken'])
glue_client = boto3.client("glue", region_name=glueSession.credentials.region)

return glueSession, client
return glueSession, glue_client

def list_schemas(self, database: str) -> List[str]:
session, client = self.get_connection()
Expand Down

0 comments on commit c3a8ef3

Please sign in to comment.