-
Notifications
You must be signed in to change notification settings - Fork 426
AWS profile support #2948
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
base: main
Are you sure you want to change the base?
AWS profile support #2948
Conversation
79e50a1 to
be62e94
Compare
kevinjqliu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Left a comment about passing profile name.
pyiceberg/catalog/glue.py
Outdated
|
|
||
| session = boto3.Session( | ||
| profile_name=properties.get(GLUE_PROFILE_NAME), | ||
| profile_name=properties.get(GLUE_PROFILE_NAME, properties.get(AWS_PROFILE_NAME)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| profile_name=properties.get(GLUE_PROFILE_NAME, properties.get(AWS_PROFILE_NAME)), | |
| profile_name=get_first_property_value(properties, GLUE_PROFILE_NAME, AWS_PROFILE_NAME), |
we have a helper function for this 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'll switch this to use get_first_property_value to keep the behavior consistent with the rest of the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add this new config to the docs
https://py.iceberg.apache.org/configuration/#s3
https://py.iceberg.apache.org/configuration/#glue-catalog
| if profile_name := get_first_property_value(properties, S3_PROFILE_NAME, AWS_PROFILE_NAME): | ||
| from aiobotocore.session import AioSession | ||
|
|
||
| session = AioSession(profile=profile_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing in the AioSession here will override the internal session object
From the docs:
https://s3fs.readthedocs.io/en/latest/api.html#s3fs.core.S3FileSystem
"""
session (aiobotocore AioSession object to be used for all connections.) – This session will be used inplace of creating a new session inside S3FileSystem. For example: aiobotocore.session.AioSession(profile=’test_user’)
"""
I think we can pass in profile name as kwarg to S3FileSystem
The kwarg will be passed into the internal AioSession object
https://github.com/fsspec/s3fs/blob/56402cd2565c5fa2aa84020c716560b3db27e8cd/s3fs/core.py#L563-L565
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds AWS profile support for the Glue catalog client and fsspec-based S3 FileIO, addressing issue #2841. Users can now explicitly configure AWS profiles through client.profile-name (unified) and s3.profile-name (S3-specific) properties, with s3.profile-name taking precedence over client.profile-name for S3 operations. Similarly, glue.profile-name takes precedence over client.profile-name for Glue catalog operations.
Changes:
- Added
AWS_PROFILE_NAMEandS3_PROFILE_NAMEconfiguration constants - Extended GlueCatalog to support fallback from
glue.profile-nametoclient.profile-name - Implemented profile support in S3FileSystem by creating AioSession with the configured profile
- Added comprehensive unit tests validating profile propagation
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pyiceberg/io/init.py | Defines new constants AWS_PROFILE_NAME and S3_PROFILE_NAME for configuration properties |
| pyiceberg/catalog/glue.py | Updates GlueCatalog to fall back to client.profile-name when glue.profile-name is not set |
| pyiceberg/io/fsspec.py | Implements profile support by creating AioSession with the configured profile for S3FileSystem |
| tests/catalog/test_glue_profile.py | Adds test verifying GlueCatalog uses client.profile-name when provided |
| tests/io/test_fsspec_profile.py | Adds tests verifying S3FileIO uses both s3.profile-name and client.profile-name |
| tests/io/test_fsspec.py | Updates existing tests to include session=None parameter in S3FileSystem assertions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| AWS_SESSION_TOKEN = "client.session-token" | ||
| AWS_ROLE_ARN = "client.role-arn" | ||
| AWS_ROLE_SESSION_NAME = "client.role-session-name" | ||
| S3_PROFILE_NAME = "s3.profile-name" |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for Unified AWS Credentials (mkdocs/docs/configuration.md lines 808-831) should be updated to include the newly added client.profile-name property. The table starting at line 823 is missing an entry for client.profile-name to document that it sets the AWS profile for both the catalog and S3 FileIO.
| S3_PROFILE_NAME = "s3.profile-name" | |
| S3_PROFILE_NAME = AWS_PROFILE_NAME |
| AWS_SESSION_TOKEN = "client.session-token" | ||
| AWS_ROLE_ARN = "client.role-arn" | ||
| AWS_ROLE_SESSION_NAME = "client.role-session-name" | ||
| S3_PROFILE_NAME = "s3.profile-name" |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The S3 FileIO configuration documentation (mkdocs/docs/configuration.md lines 112-131) should be updated to include the newly added s3.profile-name property. The table should include an entry for s3.profile-name to document that it sets the AWS profile specifically for S3 FileIO operations.
| def test_fsspec_s3_session_properties_with_client_profile() -> None: | ||
| session_properties: Properties = { | ||
| "client.profile-name": "test-profile", | ||
| "s3.endpoint": "http://localhost:9000", | ||
| **UNIFIED_AWS_SESSION_PROPERTIES, | ||
| } | ||
|
|
||
| with mock.patch("s3fs.S3FileSystem") as mock_s3fs, mock.patch("aiobotocore.session.AioSession") as mock_aio_session: | ||
| s3_fileio = FsspecFileIO(properties=session_properties) | ||
| filename = str(uuid.uuid4()) | ||
|
|
||
| s3_fileio.new_input(location=f"s3://warehouse/{filename}") | ||
|
|
||
| mock_aio_session.assert_called_with(profile="test-profile") | ||
| mock_s3fs.assert_called_with( | ||
| anon=False, | ||
| client_kwargs={ | ||
| "endpoint_url": "http://localhost:9000", | ||
| "aws_access_key_id": "client.access-key-id", | ||
| "aws_secret_access_key": "client.secret-access-key", | ||
| "region_name": "client.region", | ||
| "aws_session_token": "client.session-token", | ||
| }, | ||
| config_kwargs={}, | ||
| session=mock_aio_session(), | ||
| ) |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test case for precedence when both s3.profile-name and client.profile-name are provided. According to the PR description, s3.profile-name should take precedence over client.profile-name. A test should verify that when both properties are set, s3.profile-name is used.
| @mock_aws | ||
| def test_passing_client_profile_name_properties_to_glue() -> None: | ||
| session_properties: Properties = { | ||
| "client.profile-name": "profile_name", | ||
| **UNIFIED_AWS_SESSION_PROPERTIES, | ||
| } | ||
|
|
||
| with mock.patch("boto3.Session") as mock_session: | ||
| test_catalog = GlueCatalog("glue", **session_properties) | ||
|
|
||
| mock_session.assert_called_with( | ||
| aws_access_key_id="client.access-key-id", | ||
| aws_secret_access_key="client.secret-access-key", | ||
| aws_session_token="client.session-token", | ||
| region_name="client.region", | ||
| profile_name="profile_name", | ||
| botocore_session=None, | ||
| ) | ||
| assert test_catalog.glue is mock_session().client() |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test case for precedence when both glue.profile-name and client.profile-name are provided. According to the implementation and pattern established in the codebase, glue.profile-name should take precedence over client.profile-name. A test should verify that when both properties are set, glue.profile-name is used.
| UNIFIED_AWS_SESSION_PROPERTIES = { | ||
| "client.access-key-id": "client.access-key-id", | ||
| "client.secret-access-key": "client.secret-access-key", | ||
| "client.region": "client.region", | ||
| "client.session-token": "client.session-token", | ||
| } |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant UNIFIED_AWS_SESSION_PROPERTIES is being redefined locally instead of importing it from tests.conftest, which deviates from the established pattern in the codebase. Multiple test files (e.g., tests/catalog/test_glue.py, tests/catalog/test_dynamodb.py, tests/io/test_pyarrow.py) import this constant from tests.conftest. Consider importing it from tests.conftest to maintain consistency and avoid duplication.
| UNIFIED_AWS_SESSION_PROPERTIES = { | ||
| "client.access-key-id": "client.access-key-id", | ||
| "client.secret-access-key": "client.secret-access-key", | ||
| "client.region": "client.region", | ||
| "client.session-token": "client.session-token", | ||
| } |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant UNIFIED_AWS_SESSION_PROPERTIES is being redefined locally instead of importing it from tests.conftest, which deviates from the established pattern in the codebase. Multiple test files (e.g., tests/catalog/test_glue.py, tests/catalog/test_dynamodb.py) import this constant from tests.conftest. Consider importing it from tests.conftest to maintain consistency and avoid duplication.
| UNIFIED_AWS_SESSION_PROPERTIES = { | ||
| "client.access-key-id": "client.access-key-id", | ||
| "client.secret-access-key": "client.secret-access-key", | ||
| "client.region": "client.region", | ||
| "client.session-token": "client.session-token", | ||
| } |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant UNIFIED_AWS_SESSION_PROPERTIES is being redefined locally instead of importing it from tests.conftest, which deviates from the established pattern in the codebase. Other test files in the same directory (e.g., tests/io/test_pyarrow.py) import this constant from tests.conftest. Consider importing it from tests.conftest to maintain consistency and avoid duplication.
be62e94 to
7377d05
Compare
Closes #2841
Rationale for this change
This PR adds explicit AWS profile support for both the Glue catalog client and
fsspec-based S3 FileIO.
While
GlueCatalogalready supports profile configuration, fsspec-based S3operations did not propagate profile selection to the underlying
S3FileSystemor async AWS session. As a result, users had to rely on environmentvariables or the default AWS profile, which makes it difficult to work with
multiple AWS configurations in parallel.
This change introduces two configuration properties:
client.profile-name: a unified AWS profile for the catalog client and FileIOs3.profile-name: an AWS profile specifically for S3 FileIOProfile resolution follows this precedence:
s3.profile-nameclient.profile-nameThis ensures consistent and explicit credential selection across catalog and
FileIO layers when using the fsspec backend.
Are these changes tested?
Yes. New unit tests were added to validate the profile propagation behavior.
Glue Catalog
boto3.Session(profile_name=...)is created when initializingGlueCatalogwithclient.profile-name.S3 FileIO (fsspec)
client.profile-nameors3.profile-nameresults in thecreation of an async AWS session with the correct profile, which is then
passed to
S3FileSystem.The tests were run locally with:
Output would be:
Are there any user-facing changes?
Yes, this adds new configuration properties that users can set:
client.profile-name: Sets the AWS profile for both the catalog client and FileIO (unified configuration).s3.profile-name: Sets the AWS profile specifically for S3 FileIO.Example Usage: