Add initial support assume role credential resolver#721
Conversation
| ) | ||
| self._external_id = external_id | ||
| self._duration_seconds = duration_seconds | ||
| self._region = region or DEFAULT_STS_REGION |
There was a problem hiding this comment.
Open question: Should we expose region? We currently need this to configure the endpoint for the internal STS client and default to the global endpoint if its not specified. I think once we update our config resolution system, we can just use the top-level client's configured region instead of needing to pass it in. We can probably default to the global endpoint for now and remove this option. Curious what others think.
| ): | ||
| """Resolves AWS credentials from an STS ``AssumeRole`` call.""" | ||
|
|
||
| def __init__( |
There was a problem hiding this comment.
Just curious - it seems that the resolver exposes fewer AssumeRole inputs than the other SDKs. For example, policy / policy_arns aren't included here, while other SDKs such as Go and Kotlin already include them.
Not a blocker for initial support, but wondering if we have any plan to add more inputs in the future?
There was a problem hiding this comment.
The License Header Check is failing: the 8 generated nested STS client files are missing the Apache header (codegen only emits # Code generated...). Should we:
- simply exclude
_private/nested_clients/**in.licenserc.yaml, or - modify the codegen to add the license header to these files - maybe behind a flag so it only applies to vendored clients like this one?
Any preference on which way to go?
Important
This PR adds a standalone Assume Role credential resolver that can only be used programmatically. We do not currently support reading from a shared AWS config file and do not have a mechanism to create profile-based credential providers in the default chain. Once both land, users will be able to configure assume role credentials from their shared config file. However, this will immediately unblock anyone wishing to use assume role credentials.
Description
This PR adds an Assume Role credentials resolver the Smithy Python runtime that allows clients to source credentials from the Amazon Security Token Service (STS) using the AssumeRole API.
Changes
AssumeRoleCredentialsResolverin theidentitymodule of thesmithy-aws-corepackagesource_resolverthat must be of theAWSCredentialsResolvertype. It then converts the API output shape into anAWSCredentialsIdentity._private/nested_clients/aws_sdk_sts/that includes only theAssumeRoleoperation[assume-role]optional dependency extra insmithy-aws-corethat pulls insmithy-xmlfor the awsQuery protocol. Codegen now adds this extra to all AWS clients generated with Smithy Python to ensure they can use assume role credentials out of the box.mfa_serialand an asyncmfa_code_providercallback. The callback is invoked on every assume so a fresh, single-use token code is supplied on each credential refresh.Nested Client Generation
The nested
aws_sdk_stsclient was generated with a trimmed build projection that removes unnecessary traits such asendpointTestsanddocumentationto reduce the client size. The following is thesmithy-build.jsonused:Testing
aws-sdk-bedrock-runtimeclient.AssumeRoleCredentialResolveruses nested resolver to sign AssumeRole requestTesting script:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.