AWS Environment Variables
Theaws_env() function exports AWS credentials from configured profiles:
dot_bash_functions:1-18
How It Works
- List profiles: Checks available AWS profiles in
~/.aws/config - Validate profile: Ensures requested profile exists
- Export credentials: Sets environment variables from profile
- Display confirmation: Shows exported AWS variables
Usage
Environment Variables Set
AWS_PROFILE- Profile nameAWS_ACCESS_KEY_ID- Access key IDAWS_SECRET_ACCESS_KEY- Secret access keyAWS_DEFAULT_REGION- Default AWS region
Bitwarden Session Management
TheBW_SESSION environment variable stores your Bitwarden session token:
dot_bash_functions:20-24
Usage
Why It Matters
Chezmoi needsBW_SESSION to access Bitwarden when processing templates:
BW_SESSION:
- Templates fail to process
- Chezmoi can’t retrieve secrets
- You’ll get authentication errors
AWS Credentials from Bitwarden
AWS credentials are stored in Bitwarden and provisioned via chezmoi templates.Storage Structure
Bitwarden Item:AWS <environment>
Example: AWS work
Custom Fields:
aws_access_key_id- Access keyaws_secret_access_key- Secret keyregion- Default region
Template Example
~/.aws/credentials:
Security Best Practices
Never Commit Secrets
Use Templates for Credentials
Instead of committing credentials:bitwardenFields.
Environment Variable Lifetime
Environment variables persist only in the current shell session:Unset Sensitive Variables
Clear credentials when done:Hybrid Work/Personal Setup
This dotfiles configuration supports hybrid environments:.chezmoi.toml.tmpl:1-14
Conditional Configuration
Templates can conditionally include work or personal configs:Common Workflows
Starting Work Session
Switching Contexts
Ending Session
Troubleshooting
AWS Credentials Not Found
Profile Not Found
Ifaws_env says profile not found:
- Verify profile exists:
aws configure list-profiles - Check spelling (case-sensitive)
- Ensure credentials file has the profile section
Bitwarden Session Expired
Ifchezmoi apply fails with Bitwarden errors:
Environment Variables Not Persisting
Environment variables only exist in current shell:Adding New Environment Secrets
1. Store in Bitwarden
Create item with custom fields:- Item name:
Service Name - Custom fields:
api_key,api_secret, etc.