Skip to content

Add support for parsing and merging AWS config and credentials files#729

Open
ubaskota wants to merge 4 commits into
smithy-lang:config_integration_implementationfrom
ubaskota:config_file_support
Open

Add support for parsing and merging AWS config and credentials files#729
ubaskota wants to merge 4 commits into
smithy-lang:config_integration_implementationfrom
ubaskota:config_file_support

Conversation

@ubaskota

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Add support for parsing and merging AWS config and credentials files (~/.aws/config and ~/.aws/credentials) as part of the config resolution pipeline.

Changes:

  • Custom line-by-line parser that handles inline comments, sub-properties, and property continuations
  • Standardizer that normalizes section prefixes, handles [default] vs [profile default] precedence, and separates
    profiles/sso-sessions/services
  • ParsedConfigFile class for querying the merged result
  • Async config loading with path resolution from environment variables and defaults
  • Added support to run conformance tests (config-file-parser-tests.json and config-file-location-tests.json)+ unit tests for the query layer and file I/O edge cases

Testing:

  • Verified that the newly added and existing tests pass
  • Manually tested against a real ~/.aws/config file to verify end-to-end parsing behavior

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ubaskota
ubaskota requested a review from a team as a code owner June 24, 2026 18:56
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/__init__.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/__init__.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/__init__.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py Outdated
@ubaskota
ubaskota requested a review from a team as a code owner July 10, 2026 02:08
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/config/test_merged_config.py
Comment thread packages/smithy-aws-core/tests/unit/config/test_config_file_io.py Outdated

@SamRemis SamRemis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, clicked approve by mistake. Only the test comments are blocking

@ubaskota
ubaskota force-pushed the config_file_support branch from cb70998 to 27cbdd5 Compare July 11, 2026 21:04
@ubaskota
ubaskota changed the base branch from develop to config_integration_implementation July 11, 2026 21:20
Comment thread packages/smithy-aws-core/tests/unit/config/test_merged_config.py

@jonathan343 jonathan343 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ujjwal. Commenting on a few edge cases that seem like bugs to me. Still getting through others, but this is what I have so far.

Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/merged_config.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/exceptions.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/config/file_parser.py

@jonathan343 jonathan343 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ujjwal, this pretty much looks good to me. Had one follow up from a previews review and a comment on the missing changelog entry. Can you add a feature entry to smithy-aws-core with something like below:

Add utilities for parsing and merging shared AWS configuration and credentials files. These utilities are not yet integrated into generated clients.

current_section: str | None = None
current_key: str | None = None
in_sub_property: bool = False
ignore_continuation: bool = False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this fixes the original example, but it still fails when the invalid property is the first property in the section:

[profile p]
invalid key = ignored
  continuation

This currently raises:

ConfigParseError: Line 3: Expected a property definition, found continuation

current_key is checked before ignore_continuation, so the continuation is only ignored when an earlier valid property populated current_key. Could we check ignore_continuation first and reset it when entering a new section? It would also be useful to test this case without a preceding valid property.

@jonathan343 jonathan343 changed the title Add config file support for config resolution Add support for parsing and merging AWS config and credentials files Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants