Skip to content

Add AWS Process Credential Resolver - #658

Open
jonathan343 wants to merge 14 commits into
developfrom
process-cred-resolver
Open

Add AWS Process Credential Resolver#658
jonathan343 wants to merge 14 commits into
developfrom
process-cred-resolver

Conversation

@jonathan343

@jonathan343 jonathan343 commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds an AWS process-based credentials resolver to smithy-aws-core so credential providers can source credentials from an external command, while handling the common failure modes and caching behavior expected for both long-lived and temporary credentials.

This PR adds AWS process-based credential support to smithy-aws-core. It introduces a ProcessCredentialsResolver that sources credentials from an external command, and wires it into the default AWS identity chain so that a profile's credential_process setting is automatically honored. It also handles the common failure modes and caching behavior expected for both long-lived and temporary credentials.

Testing

Note

This was tested with internal AWS process tools for sourcing credentials. TODO: Test with popular external tools.

The identity chain is currently opt-in. We'll construct one and set it as the config's credentials resolver. Once set, credentials sourced from a credential_process profile are resolved through the chain:

# ~/.aws/config
[default]
credential_process = <insert command here>

Example Script:

import asyncio

from aws_sdk_bedrock_runtime.client import AsyncBedrockRuntimeClient
from aws_sdk_bedrock_runtime.config import Config
from aws_sdk_bedrock_runtime.models import (
    ContentBlockText,
    ConverseInput,
    Message,
)
from smithy_aws_core.identity import AWSCredentialsIdentity, IdentityChain


async def main():
    identity_chain = await IdentityChain.create(AWSCredentialsIdentity)
    client = AsyncBedrockRuntimeClient(
        config=Config(
            region="us-west-2",
            aws_credentials_identity_resolver=identity_chain,
        )
    )
    input_message = Message(
        role="user", content=[ContentBlockText(value="What is boto3?")]
    )
    response = await client.converse(
        ConverseInput(
            model_id="global.amazon.nova-2-lite-v1:0", messages=[input_message]
        )
    )

    output_message = response.output
    print(output_message)


asyncio.run(main())

The resolver can also be used directly, bypassing the chain and profile configuration entirely:

from smithy_aws_core.identity import ProcessCredentialsResolver

resolver = ProcessCredentialsResolver(command=["<insert command here>"])

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

@jonathan343
jonathan343 force-pushed the process-cred-resolver branch from 0e39eb8 to 246f957 Compare March 16, 2026 15:15
@jonathan343
jonathan343 marked this pull request as ready for review March 16, 2026 16:51
@jonathan343
jonathan343 requested a review from a team as a code owner March 16, 2026 16:51
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
@jonathan343
jonathan343 requested a review from a team as a code owner July 24, 2026 05:31
@jonathan343
jonathan343 force-pushed the process-cred-resolver branch from e341b1c to 0c48d90 Compare August 2, 2026 05:31

@jonathan343 jonathan343 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm bringing this PR back to life now that we have a foundation for the default credentials chain and config resolution. I've adapted this to the pattern introduced in #749.

Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/tests/unit/identity/test_process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py
Comment thread packages/smithy-aws-core/src/smithy_aws_core/identity/process.py Outdated
return shlex.split(command)


def _split_windows_command(command: str) -> list[str]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewer: This is inspired by botocore's _windows_shell_split utility function.

from .conftest import OtherIdentity


@pytest.mark.parametrize(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewer:

Most cases are ported from botocore: https://github.com/boto/botocore/blob/develop/tests/unit/test_compat.py#L111-L134

I also added two realistic Windows path cases

@jonathan343
jonathan343 requested a review from arandito August 2, 2026 18:42
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