Support assume-role for Glue and DynamoDB catalogs - #3838
Open
lemon0333 wants to merge 1 commit into
Open
Conversation
Extend the existing S3 FileIO assume-role mechanism (client.role-arn / client.role-session-name) to the boto3 sessions built by GlueCatalog and DynamoDbCatalog. When a role ARN is configured, an STS AssumeRole is performed from the base session and the resulting temporary credentials are used for the Glue/DynamoDB client. Role configuration follows the same precedence already used for the other client.* properties: a service-prefixed override (glue.role-arn / dynamodb.role-arn, glue.role-session-name / dynamodb.role-session-name) falls back to the unified client.role-arn / client.role-session-name. Default behavior (no role ARN configured) is unchanged. Closes apache#2747 Signed-off-by: lemon0333 <147061193+lemon0333@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2747
Rationale for this change
At the moment, assume-role (
client.role-arn/client.role-session-name, via STS) is only honored by the S3 FileIO (pyiceberg/io/pyarrow.py). The AWS catalogs (Glue, DynamoDB) build their ownboto3.Sessionand ignore these properties, so users who authenticate to AWS by assuming a role cannot use it to reach the catalog — even though the otherclient.*properties (region, access key, etc.) are already shared between S3 FileIO and the catalogs.This PR extends the same assume-role behavior to the
GlueCatalogandDynamoDbCatalogboto3 sessions:_get_aws_session_with_assumed_role()(inpyiceberg/catalog/__init__.py) performs the STSAssumeRolefrom the base session and returns a new session using the returned temporary credentials.client.*properties: a service-prefixed override falls back to the unified property:glue.role-arn/dynamodb.role-arn→client.role-arnglue.role-session-name/dynamodb.role-session-name→client.role-session-nameI've kept the new service-prefixed property names consistent with the existing
glue.*/dynamodb.*→client.*convention, but I'm happy to adjust the naming (e.g. unified-only) to match maintainer preference — feedback welcome.Are these changes tested?
Yes. New
moto-based tests (mock STS + Glue + DynamoDB) intests/catalog/test_glue.pyandtests/catalog/test_dynamodb.pycover:client.role-arn/client.role-session-name;glue.role-arn/dynamodb.role-arn) take precedence over the unified ones;Are there any user-facing changes?
Yes — new opt-in configuration properties for assuming an IAM role when connecting to the Glue/DynamoDB catalogs:
client.role-arn/client.role-session-name(now honored by the catalogs too), plus service-specificglue.role-arn/glue.role-session-nameanddynamodb.role-arn/dynamodb.role-session-name. Documented inmkdocs/docs/configuration.md. No change to default behavior.