kevinjqliu commented on code in PR #1299: URL: https://github.com/apache/iceberg-python/pull/1299#discussion_r1831452825
########## pyiceberg/catalog/glue.py: ########## @@ -296,13 +306,48 @@ class GlueCatalog(MetastoreCatalog): def __init__(self, name: str, **properties: Any): super().__init__(name, **properties) + credentials = Credentials( + access_key=get_first_property_value(properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID), + secret_key=get_first_property_value(properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY), + token=get_first_property_value(properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN), + ) + session = boto3.Session( profile_name=properties.get(GLUE_PROFILE_NAME), region_name=get_first_property_value(properties, GLUE_REGION, AWS_REGION), - aws_access_key_id=get_first_property_value(properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID), - aws_secret_access_key=get_first_property_value(properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY), - aws_session_token=get_first_property_value(properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN), + aws_access_key_id=credentials.access_key, + aws_secret_access_key=credentials.secret_key, + aws_session_token=credentials.token, ) + + if role_arn := get_first_property_value(properties, GLUE_ROLE_ARN, AWS_ROLE_ARN): + extra_args = {} + if role_session_name := get_first_property_value(properties, GLUE_ROLE_SESSION_NAME, AWS_ROLE_SESSION_NAME): + extra_args["RoleSessionName"] = role_session_name + + fetcher = AssumeRoleCredentialFetcher( + client_creator=session.client, + source_credentials=credentials, + role_arn=role_arn, + extra_args=extra_args, + ) + refreshable_credentials = DeferredRefreshableCredentials( + method="assume-role", + refresh_using=fetcher.fetch_credentials, + ) + from botocore.session import Session as BotoSession + + botocore_session = BotoSession() Review Comment: Im leaning towards loading custom clients instead of passing everything through properties. Every time we add another property, we need to map a name, a possible default, and pass to the underlying object. The logic above is already pretty complicated, might as well split it out and call it something like `RefreshableGlueClient` ########## pyiceberg/catalog/glue.py: ########## @@ -296,13 +306,48 @@ class GlueCatalog(MetastoreCatalog): def __init__(self, name: str, **properties: Any): super().__init__(name, **properties) + credentials = Credentials( + access_key=get_first_property_value(properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID), + secret_key=get_first_property_value(properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY), + token=get_first_property_value(properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN), Review Comment: took me a long time to find this, but it looks like `token` is correct here https://github.com/boto/botocore/blob/179e8b5361cd83d4c4acdf0c1bc1708b4a6966e9/botocore/session.py#L944-L948 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org