gptel-bedrock: allow configuring AWS profile via gptel-make-bedrock #996
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.
The
gptel-make-bedrock
function now accepts a:profile
keyword argument. This allows an AWS profile to be specified directly in the backend configuration, overriding any environment variables.The credential resolution order has been updated to prioritize the most specific configuration:
AWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
environment variablesAWS_PROFILE
environment variableThis makes managing AWS credentials more flexible and robust, especially for users who interact with multiple AWS accounts or prefer to keep their configuration self-contained within Emacs.
Here are the key benefits:
Context-Specific Configurations: Users often work with different AWS accounts for various purposes (e.g., a personal account, a work development account, and a work production account). This feature allows you to define multiple
gptel
backends, each configured to use a specific AWS profile. You can then easily switch between these backends within Emacs without altering your system-wide environment variables.Self-Contained Emacs Configuration: For users who prefer to manage their entire workflow within Emacs, this change allows them to define AWS profiles directly in their Emacs configuration files (e.g.,
init.el
). This eliminates the dependency on external shell environment variables likeAWS_PROFILE
, making the setup cleaner and more portable across different machines.Clarity and Reproducibility: Explicitly defining the profile in the backend configuration makes it transparent which set of credentials is being used. This is particularly valuable for literate programming or computational notebooks, as it documents the execution context directly alongside the code, improving reproducibility.
Override Global Defaults: A user might have a default
AWS_PROFILE
set in their shell for general command-line use. This feature provides a convenient way to override that default for tasks performed within Emacs, without affecting the environment in their terminal.